Redirect URLS with Apache mod_rewrite

扶醉桌前 提交于 2020-01-06 19:28:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!