簡體   English   中英

.htaccess 301重定向到新的URL結構

[英].htaccess 301 redirect to a new URL structure

我有以下URL結構,我需要301一個新的URL結構。

舊結構/bla-bla-bla-400252596261.html

新結構/listing/bla-bla-bla-400252596261.html

我怎樣才能在.htacces中實現這一目標?

編輯:我在根上有其他文件,但不是以.html結尾所以它應匹配該字符串。 因此,根目錄中與.html擴展名匹配的任何文件都應重定向到/listing/bla-bla-bla-400252596261.html頁面。

嘗試這個:

RewriteCond %{REQUEST_URI} ^/.*\.html$
RewriteCond %{REQUEST_URI} !^/listing.*
RewriteRule ^(.*\.html)$ /listing/$1 [R=301,QSA,L]

這里有更多例子

暫無
暫無

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

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