我有mod_rewrite的麻煩。RewriteRule給出404
我有位於'wp'目錄的wordpress網站。它可作爲http://localhost/wp/
網站上有頁http://localhost/wp/sample-page/
。
我想使這個頁面打開與http://localhost/wp/sample-page-2/
沒有重定向。
以下是在.htaccess文件:
RewriteEngine On
RewriteBase /wp/
RewriteRule ^sample-page-2/$ sample-page/ [L]
但我發現了404錯誤。
有人可以解釋我做錯了什麼嗎? 在此先感謝。
UPD:
@soju:嗯, 「樣品頁-2」 - 就是例子
- 它不是worpress SENCE頁/後。
- 其實我試圖給url添加一段。例如。
http://localhost/wp/sample-page/section/
。而這個規則RewriteRule ^sample-page/section/$ sample-page/ [L]
沒有工作。然後我決定「簡化」url(「sample-page-2」而不是「sample-page/section」) - 沒有成功。
UPD2
BTW,重定向RewriteRule ^sample-page-2/$ sample-page/ [R=301,L]
工作
爲什麼不直接修改頁面塞? – soju
@soju:看到更新後的帖子 –