簡體   English   中英

使用Apache mod_rewrite重定向URL

[英]Redirect URLS with Apache mod_rewrite

我正在嘗試重定向Apache Web服務器上收到的URL。 基本上當我打字

本地主機/index.html

我希望網站將我重定向到htdocs中readme.html文件。 index.htmlreadme.html文件都保存在htdocs中 我查看了Apache文檔,但似乎無法正常工作。 下面,我將到目前為止已編寫的代碼包含在httpd.conf文件中。

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>

我已經嘗試在瀏覽器中尋找“ localhost / index.html”,但是卻看到了index.html頁面。 除非我看錯了。 謝謝

試試看

<Directory "usr/local/apache2/htdocs">
#your other code here#
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ readme.html [R,NC]
</Directory>

清除緩存並刪除臨時Internet文件始終是一件好事。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM