[英]Issue with Rewrite Rule in .htaccess file
我打算將我的網頁網址轉換為seo友好。 我的網址鏈接如下
http://example.com/display.php?id=***
現在我想將其轉換為seo友好的網址,這可能是
http://example.com/partners-id-***.html
像上面的東西。 我用了
RewriteEngine On
RewriteRule ^partners-id-([^-]*)\.html$ /display.php?id=$1 [L]
在htaccess文件中重寫規則。 但網址仍然與舊網址相同。 任何人都可以幫助我解決此問題???
在此規則進行外部重定向之前,您還需要1條301規則:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+display\.php\?id=([^\s&]+) [NC]
RewriteRule ^ /partners-id-%1.html? [R=301,L]
RewriteRule ^partners-id-([^.]*)\.html$ /display.php?id=$1 [L,QSA]
正如Justin和其他人所評論的那樣,最好將您的鏈接更改為/partners-id-123.html
。 但是,對於已經由搜索引擎緩存的鏈接,請遵循此處的第一個規則,它將進行301重定向:
/display.php?id=1234 => /partners-id-1234.html
請嘗試如下:
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /display.php?id=$1 [L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.