Forum Moderators: phranque
Here is part of my httpd:
DocumentRoot "C:/Apache Group/Apache2/htdocs"
DirectoryIndex index.html index2.html
If someone type in http://example.com, it will automatically
show the index.html on the browser. This works.
However, I have an index.html in a directory abcde
and want to automatically show the index.html in abcde
when people type http://example.com/abcde. This
does not work.
I have to have people using [mydomain.com...]
to show the index.html in abcde directory.
How do I set up my httpd file to skip the requirement
of the last slash? Most people do not know the last slash is required.
Thanks
[edited by: jdMorgan at 11:27 pm (utc) on Jan. 20, 2010]
[edit reason] Please use "example.com" [/edit]
If you wish to override this correct behavior on Apache 2.x, then refer to the Apache documentation for the DirectorySlash directive.
I would warn you that doing so violates Web standards, so this 'fix' --while it may seem expedient today-- may come back to cause problems for you in the future.
A better solution would be to 301-redirect requests with missing trailing slashes to correct the URL, instead of 'just accepting' the error and correcting it inside the server.
Jim
Thanks for a quick reply.
The default DirectorySlash is On.
My understanding is that the trailing slash should be automatically added to the url without the trailing slash.
I even added DirectorySlash On and there is no difference.
The only machines that work is the servers. Any other machines needs the trailing slash to show the index.html.
Any suggestion to do it in Server side.
Jason
I did check for the mod_dir. The lines are:
LoadModule access_module modules/mod_access.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_module modules/mod_auth.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule imap_module modules/mod_imap.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule ssl_module modules/mod_ssl.so
The strangest thing is the automatic trailing slash works in
the machines that have a copy of the Apache setup running. But the automatic trailing slash does not work on other machines, like client machines browsing my site.
In .htaccess or inside a <Directory> container in a server config file:
RewriteCond $1 !\.[a-z0-9]$ [NC]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.*[^/])$ http://www.example.com/$1/ [R=301,L]
Jim