.htaccess多个参数不起作用

时间:2017-11-13 23:25:38

标签: apache .htaccess url-rewriting

我遇到htaccess规则的问题因为无法正常工作。我已经尝试在谷歌上找到任何解决方案但仍未找到。 代码是:

RewriteEngine ON
RewriteBase /deshop/
RewriteCond %{REQUEST_URI} ^/deshop/admin(.+)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ admin/index.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)$ index.php?p=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^\s]+)$ index.php?p=$1&b=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([0-9]+)$ index.php?p=$1&id=$2 [L]

网址正常运作:

http://localhost/deshop/index.php to http://localhost/deshop/ -> home page from folder
http://localhost/deshop/admin/index.php to http://localhost/deshop/admin/ -> admin page from subfolder
http://localhost/deshop/index.php?p=tshirts to http://localhost/deshop/tshirts/
http://localhost/deshop/index.php?p=brand&b=John%20Player to http://localhost/deshop/brand/John-Player/

发生这种情况,最后一条规则不起作用。

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([0-9]+)$ index.php?p=$1&id=$2 [L]

但最后一条规则尚未奏效。我真的很难。我想获取带参数的url,所以看起来很有效:

http://localhost/deshop/index.php?p=single&id=0005 to http://localhost/deshop/single/0005

或者,我错了什么?有解决方案吗你能帮助我吗?非常感谢。顺便说一下,我的英语不好。对不起!

1 个答案:

答案 0 :(得分:0)

最后我解决了它。

web extensions