user1126720
user1126720

Reputation: 108

Created apache alias directory, but not working

I have created an apache alias directory so that I can access the directory from outside the root folder with the same url...

The problem is that it refuse to work without a trailing slash. As an example if the site name is

error Cannot find server appears.

However if I enter

it works.

Any Idea how to fix this issue?

Upvotes: 6

Views: 18810

Answers (3)

hakre
hakre

Reputation: 198237

www.example.com/aa will make apache first look for a file called aa. As it doesn't exists, you should get a 404 error.

Whereas www.example.com/aa/ will match your alias directive which works on directories (not files AFAIK). At least I've experienced this on windows.

You might want to use the AliasMatch directive instead:

AliasMatch ^/icons(.*) /usr/local/apache/icons$1

Upvotes: 0

rekire
rekire

Reputation: 47995

Add a mod rewrite rule:

RewriteEngine On
RewriteRule /aa /aa/

Upvotes: 3

Rajat Singhal
Rajat Singhal

Reputation: 11264

Why Wamp Server doesn’t do this automatically, I’m not sure, but at least there’s a simple fix.

Click on the Wamp Server 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.

For Example

Alias /example/ "c:/path/to/example/"

Would become

Alias /example "c:/path/to/example/"

Save the file and close Notepad.

Wamp Server should restart automatically (if not, do it manually). Once it has restarted, you’re alias should now work with or without the trailing slash.

Upvotes: 9

Related Questions