.htaccess重写几个参数的规则

时间:2014-04-04 17:02:53

标签: apache mod-rewrite url-rewriting

我找到了一些有用的链接,但我无法弄清楚为什么不能正常工作。 目前的网址:

http://localhost/noyk/clients/clients.php?name=StackOverflow&category=technology

我想要的最终网址是:

http://localhost/noyk/clients/StackOverflow/technology 

我找到了this话题,我已经尝试过了。

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^([^/]+)/([^/]+)/?$ index.php?name=$1&category=$2 [L,QSA]
RewriteRule ^([^/]+)/?$ index.php?name=$1 [L,QSA]

如果你们告诉我这应该有用,那就不行了。

当我输入网址http://localhost/noyk/clients/StackOverflow时,我收到默认的XAMPP网页错误:

The requested URL /noyk/clients/StackOverFlow was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

1 个答案:

答案 0 :(得分:0)

我猜你的.htaccess文件在你的网站根目录中?如果是这样,移动到/ noyk / clients /或编辑如下:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^noyk/clients/([^/]+)/([^/]+)/?$ index.php?name=$1&category=$2 [L,QSA]
RewriteRule ^noyk/clients/([^/]+)/?$ index.php?name=$1 [L,QSA]