问题
I'm trying to redirecting URLS received on my Apache web server. Basically when I type
localhost/index.html
I want the website to redirect me to a readme.html
file inside the htdocs. index.html
and readme.html
files both are saved in the htdocs. I looked at the Apache documentation but I cannot seem to get this working. Below I have included the code I have wrote so far inside the httpd.conf
file.
DocumentRoot "usr/local/apache2/htdocs"
<Directory "/htdocs">
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
RewriteEngine On
RewriteBase /
RewriteRule ^index.html readme.html [PT]
</Directory>
I have tried on my browser looking for "localhost/index.html" , however I am seeing the index.html page. Unless I am looking at it wrong. Thanks
回答1:
Try this out
<Directory "usr/local/apache2/htdocs">
#your other code here#
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ readme.html [R,NC]
</Directory>
Its always good to clear cache and delete temporary internet files.
来源:https://stackoverflow.com/questions/33787392/redirect-urls-with-apache-mod-rewrite