[英]SEO friendly URLs (.htaccess)
http://www.domain.com/folder/file?x=1&y=2
改成:
http://www.domain.com/folder/file/1/2/
http://www.domain.com/folder/?x=1
改成:
http://www.domain.com/folder/1/
我試過了:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder/(.*)/$ folder/index.php?x=$1 [L]
RewriteRule ^folder/file/(.*)/(.*)/$ folder/file.php?x=$1&y=$2 [L]
但這行不通,有人知道為什么嗎?
當我刪除第一條規則時,我可以通過以下方式訪問第二條規則:
http://www.domain.com/folder/1/2/
但不是:
http://www.domain.com/folder/file/1/2/
天哪,我希望我不會混淆正在閱讀此笑的任何人,我希望這是有道理的
嘗試
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder/file/(.*)/(.*)/ /folder/file.php?x=$1&y=$2 [L]
RewriteRule ^folder/(.*)/ /folder/index.php?x=$1 [L]
規則的順序很重要。 當您到達第一個規則時,應該始終將規則最多的規則放在第一位,然后停止,因為由於(.*)
正在捕獲file
所以它始終為真。
您是否嘗試在文件夾名稱前添加/?
RewriteRule ^folder/(.*)/$ /folder/index.php?x=$1 [L]
RewriteRule ^folder/file/(.*)/(.*)/$ /folder/file.php?x=$1&y=$2 [L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.