繁体   English   中英

重新写入长网址规则

[英]ReWrite rule for long URL

我正在遵循重写规则广告

RewriteEngine On
RewriteCond ${REQUEST_URI} ^.+$
RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g|png|js|css|swf|php|ico|txt|pdf|xml)$ [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]

RewriteRule ^(.*)/(.*)/?$ index.php?rt=$1/$2  [L]
RewriteRule ^(.*)/(.*)/(.*)/?$ index.php?rt=$1/$2/$3  [L]

如果网址是http://www.example.com/manage/ne/new?query=123 means ,我将使用php中的“ $ _GET”获取通过URL传递的“查询”的值。

它会像` http://www.example.com/index.php?rt=manage/ne/new

但我的需要是http://www.example.com/index.php?rt=manage/ne/new&query=123

有谁能帮助我解决有关Htacces的问题。

您需要在底部2条规则中使用QSA标志:

RewriteRule ^([^/]+)/(.+)/?$ index.php?rt=$1/$2  [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/(.+)/?$ index.php?rt=$1/$2/$3  [L,QSA]

QSA (查询字符串追加)标志在添加新参数时保留了现有查询参数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM