Domain Name Slash Prevention

I want my site to appear as www.mysite.com , not www.mysite.com/

By default, does Apache add a trailing slash after the domain name or add a browser? If I want to prevent this using .htaccess, then what would be the rule for rewriting url?

+4
source share
4 answers

http://www.searchenginejournal.com/linking-issues-why-a-trailing-slash-in-the-url-does-matter/13021/

http://www.alistapart.com/articles/slashforward/

URLs were first used to model directories, so a trailing slash is required. I think that if you don't have the trailing slash, some web servers will not be able to find the content correctly.

+2
source

As explained by Anthony's first link, the slash is part of the address. Each domain (and not just the "vast majority") has a name that resembles www.mysite.com, but it's just a domain name, not a URL. The URL is the file address, i.e. protocol + domainname + pathfile, so http://www.mysite.com/ the missing file name is added using DirectoryIndex and therefore is the URL, but http://www.mysite.com is just doesn’t mean anything, because in this case the path to the file will be empty. The fact that your browser does not display the boring parts of your URL is not related to the setting up of your website.

If indeed the same browser behaves differently on different sites, I would be interested to know which browser and which websites you used.

+2
source

If you request:

http://myhost.com

The request should look like this in HTTP:

GET / HTTP / 1.0
Host: myhost.com

For historical reasons, some browsers have added a slash because otherwise it translates to

GET <nothing> HTTP / 1.0
Host: myhost.com

What will be the illegal request.

Note that:

http://myhost.com/page

is legal as it translates into:

GET / page HTTP / 1.0
Host: myhost.com

+2
source

The browser automatically adds such a slash when requesting a URL. How to display this in the address bar is another story.

For example: www.adobe.com - enter it in different browsers and see how it displays it:

  • Firefox (Windows 6.0.2) = http://www.adobe.com/
  • Google Chrome (Windows, 13.0.782.220 m) = www.adobe.com
  • Opera (Windows 11.51) = www.adobe.com
  • Internet Explorer 9 = http://www.adobe.com/
+1
source

All Articles