[英]wordpress redirect issue in htaccess file
我在.htaccess文件中有一些問題rewriterule。 我要在wordpress網站上關注以下內容。 當我在瀏覽器上轉到http://www.test.com/test/subtest/postname時,我將看到與http://www.test.com/postname相同的結果,並且網址不必是重定向換句話說,瀏覽器的網址無需更改
我像下面一樣嘗試了它,但在.htaccess文件中有很多工作
.htaccess
...
RewriteRule ^test/subtest/(*)$ /$ [R=301, L]
...
謝謝
您的正則表達式匹配以及重定向都出錯。
(.*)
來匹配匹配組中0個或更多字符 $1
在您的重定向中引用匹配的組 RewriteRule
應該如下所示:
RewriteRule ^test/subtest/(.*)$ /$1 [R=301, L]
您可以在以下位置進行測試: http : //htaccess.madewithlove.be/
output url
http://www.example.com/postname
debugging info
1 RewriteRule ^test/subtest/(.*)$ /$1 [R=301, L]
This rule was met, the new url is http://www.example.com/postname
Test are stopped, because of the R in your RewriteRule options.
A redirect will be made with status code 301
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.