Reputation: 347
In my httpd.conf file of my apache server(on windows7), I used LoadModule alias_module modules/mod_alias.so And then I modified the httpd.conf with the following:
<IfModule alias_module>
Alias /b /blog
ScriptAlias /cgi-bin/ "cgi-bin/"
</IfModule>
After I restarted the server and type the localhost/b in my address bar,however,it did not redirect to the localhost/blog.I don't konw why.Can you help me, Any help is greatly appreciated
Upvotes: 1
Views: 4164
Reputation: 122364
Alias declarations aren't the same as redirects.
Alias /b /blog
tells Apache to make the files that exist on your file system under the path /blog
(which doesn't mean much on Windows) available at the URL http://myserver.com/b
, i.e. a request for http://myserver.com/b/something.html
will try to return the content of the file /blog/something.html
from your filesystem, failing if that file does not exist - the browser address bar will still say http://myserver.com/b/something.html
.
It sounds like what you're after is
Redirect /b http://myserver.com/blog
In this case, a request for http://myserver.com/b/something.html
will result in an HTTP redirect, the browser's address bar will change to say http://myserver.com/blog/something.html
.
Of course, you then need to ensure that /blog
resolves appropriately, which may require its own Alias
if it's not under the DocumentRoot
.
Alias /blog "C:/web/blog"
<Directory "C:/web/blog">
Order allow,deny
Allow from all
</Directory>
Upvotes: 2