Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the trailing slash in the web service is so important?

I was testing a web service in PHP and Python. The address of the web service was, let's say, http://my.domain.com/my/webservice. When I tested the web service in PHP using that URL everything worked fine. But, when I used the same location but in Python using SOAPpy I got an error.

Below is the code I used to communicate with the web service (Python):

from SOAPpy import WSDL
server = SOAPProxy('http://my.domain.com/my/webservice', namespace)
server.myFunction()

The respond I got from the server:

HTTPError: <HTTPError 301 Moved Permanently>

I figure out that if I add a trailing slash to the web service location it works!

from SOAPpy import WSDL
server = SOAPProxy('http://my.domain.com/my/webservice/', namespace)
server.myFunction()

Why the lack of the trailing slash causes the error?

like image 256
czuk Avatar asked Jul 27 '09 15:07

czuk


People also ask

Why is trailing slash important?

Trailing slashes can split your link equity in half It's the idea that when web pages link to other pages, they're endorsing that content by transferring link equity. The more link equity a page has, the more powerful the endorsement. It's the underlying principle behind 'PageRank', one of Google's original algorithms.

Why do URLs have trailing slash?

A trailing slash is a forward slash (“/”) placed at the end of a URL such as domain.com/ or domain.com/page/. The trailing slash is generally used to distinguish a directory which has the trailing slash from a file that does not have the trailing slash. However, these are guidelines and not requirements.

Does the slash at the end of a URL matter?

The short answer is that the trailing slash does not matter for your root domain or subdomain. Google sees the two as equivalent. But trailing slashes do matter for everything else because Google sees the two versions (one with a trailing slash and one without) as being different URLs.


1 Answers

They're different URLs. http://my.domain.com/my/webservice implies a file webservice in the my folder. http://my.domain.com/my/webservice/ implies the default document inside the my/webservice folder.

Many webservers will automatically correct such URLs, but it is not required for them to do so.

like image 95
Yuliy Avatar answered Sep 20 '22 15:09

Yuliy