Mobile app version of vmapp.org
Login or Join
Shakeerah822

: WAMPServer 404s a directory URL unless it ends with a trailing slash How can I set Apache so that it doesn't require the trailing slash on the end of the directory? e.g. http://localhost/test

@Shakeerah822

Posted in: #Apache2 #Wampserver

How can I set Apache so that it doesn't require the trailing slash on the end of the directory?

e.g. localhost/test will result in 404, whereas localhost/test/ will display the index.html file for that directory.

Update:

I should add that the example /test/ directory is in fact an alias.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Shakeerah822

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

I've just noticed @dan 's comment above. If /test/ is indeed an Apache Alias, as set by WAMPServer, then the DirectorySlash may not be the problem after all. Both solutions are presented below.



DirectorySlash directive

You need to set DirectorySlash On in your Apache config (or .htaccess). This instructs mod_dir to implicitly append a slash in the case you mention; when the URL points to a directory.

However, this is normally On by default, so it's likely there is a DirectorySlash Off somewhere that is explicitly disabling this? So it may be preferable to find this and simply remove it.

Reference: httpd.apache.org/docs/2.4/mod/mod_dir.html#directoryslash


Apache Alias set by WAMPServer

The solution regarding the Apache Alias (as set by WAMPServer) is contained in the Wamp Alias Directories article as linked to by @dan in the comments above.

An Apache Alias (mod_alias) allows you to serve files from a different location on your filesystem as if they are stored under the document root. So, in the case of the /test directory above, this (as it turns out) is an alias for a different location on the local filesystem.

WAMPServer provides its own interface for creating this Alias. However, in doing so it appears to append a slash to the URL-path, so /test becomes /test/. This means that you will need to also append this slash to the requested URL, otherwise it will not match!

The solution to this is to manually edit the alias file and remove this slash. From the linked article:


Click on the Wamp Server tray icon again and select Apache → Alias directories → [alias url] –> Edit alias. This will open the alias file in Notepad. Remove the trailing slash from the relative URL.


Reference: httpd.apache.org/docs/2.4/mod/mod_alias.html#alias http://willi.am/blog/2009/01/14/wamp-alias-directories/

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme