使用htaccess的seo友好网址问题

时间:2014-07-01 13:01:08

标签: apache .htaccess mod-rewrite

我遇到了htaccess的问题。

我的非seo友好网址看起来像这样

http://localhost/mybb/index.php?url=login/register

,代码是

Options -MultiViews
RewriteEngine On
RewriteBase /mybb/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

然后返回http://localhost/mybb/login/register这绝对没问题,现在我正在尝试修改看起来像这样的网址

http://localhost/mybb/login/register/step/1

原始网址是

http://localhost/mybb/index.php?url=login/register&step=1

我试过这个

RewriteRule ^(.+)$ index.php?url=$1&step=1$ [QSA,L]

它使用了具有步骤作为参数的网址,但是如果没有“步骤”的话。在网址中,它不起作用。只有当实际网址包含名为' step'。谢谢

的参数时,才可以在seo网址中添加/ step / 1

解决

最后一行应该是

RewriteRule ^(.*)/(.*) index.php?url=$0&step=$2 [L,QSA] 

关闭RewriteCond %{REQUEST_FILENAME} !-l

0 个答案:

没有答案