![](/img/trans.png)
[英]Apache mod_rewrite path to query string for specific path format
[英]htaccess mod_rewrite two query string parameters to path format
我將如何改變
http://example.com/?sort=top&time=variable
至
http://example.com/top/variable
&time=variable
可能不會始終使用。
我當前的htaccess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?showcase/(.*?)/?$ /showcase.php?id=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /showcase\.php\?id=([^\&\ ]+)
RewriteRule ^/?showcase\.php$ /showcase/%1? [L,R=301]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
重寫http://example.com/showcase.php?id=int
到http://example.com/showcase/int
。
如果代碼在.htaccess
文件中,請使用^
代替^/?
。 對於您的特殊情況,您可以按如下所示修改/添加到現有的重定向中:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(top)(?:/([^/])+)?/?$ /?sort=$1&time=$2 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?sort=(top)(?:&time=([^\s&]+))? [NC]
RewriteRule ^ /%1/%2? [R=301,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.