簡體   English   中英

URL 新聞 ID 的重寫規則

[英]RewriteRule for URL News ID

我有點堅持 RewriteRule 301,從舊新聞 ID 更改為新新聞 ID

這是我嘗試過的:

RewriteRule ^/news/0(.*)$ /news/$1 [L,R=301]

假設新聞 URL 看起來像他的:

http://www.mydomain.com/news/01/title-of-the-new
http://www.mydomain.com/news/09/title-of-the-new
http://www.mydomain.com/news/012/title-of-the-new
http://www.mydomain.com/news/032/title-of-the-new

我想改為:

http://www.mydomain.com/news/1/title-of-the-new
http://www.mydomain.com/news/9/title-of-the-new
http://www.mydomain.com/news/12/title-of-the-new
http://www.mydomain.com/news/32/title-of-the-new

我設法修復它替換

RewriteRule ^/news/0(.*)$ /news/$1 [L,R=301] 

RewriteRule ^news/0(.*)$ /news/$1 [L,R=301]

你為什么需要它? 您的規則應該可以解決問題,但不是您需要的(我認為)。 It runs you server-side srcipts whith URL http://www.mydomain.com/news/1/title-of-the-new when you opening http://www.mydomain.com/news/01/title-of -新的

我認為刪除所有前零的更強大的規則會更好一些:

重寫規則 ^news/0+(.*)$ /news/$1 [L,R=301]

暫無
暫無

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

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