I haven't really noticed this Redirect(301) when requesting a url like this without slash("/") at the end: http://server/directory
The server will respone with a 301 Redirect Permanent header with a Location header locating to http://server/directory/
.
See this live example:
User Request:
GET /social HTTP/1.1
( http://192.168.1.111/social )
Apache Server Responce:
HTTP/1.1 301 Moved Permanently
Location: http://192.168.1.111/social/
User Request:
GET /social/ HTTP/1.1
( http://192.168.1.111/social/ )
Apache Server Responce:
HTTP/1.1 200 OK
Apache access.log:
192.168.1.130 - - [05/Apr/2014:22:06:47 +0200] "GET /social HTTP/1.1" 301 558 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0"
-
192.168.1.130 - - [05/Apr/2014:22:06:47 +0200] "GET /social/ HTTP/1.1" 200 942 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:27.0) Gecko/20100101 Firefox/27.0"
The /social/ directory contains an index.html
file.
Apache Software: Apache/2.2.22 (Ubuntu)
Directory Options: Options Indexes FollowSymLinks MultiViews
So, my question is: Why is apache doing this? And how to prevent the redirect and send out the index.html
directly? Clients have to send two requests which is really unnecessary. And maybe some of the clients doesn't allow Redirects and will not be able to go to the site without the ending slash ("/").
I don't want to disable the redirect. I wan't the server to send out the response directly without any redirect. Even when requesting /social
.
Is apache designed to redirect those requests? The server could just send the data without redirecting, right? Should I use the mod_rewrite
to prevent this? Or another configuration? Or should I just let it be like this and add a slash at the end of all html links and live with some redirects?
What do you guys think?