如何使用相同数量的参数重写2个URL?

时间:2014-08-22 07:18:13

标签: apache .htaccess mod-rewrite url-rewriting

我们尝试使用相同数量的参数重写两个网址,如下所示。

 URL 1: www.build99.com/5/Electricals
 URL 2: www.build99.com/10/Civil

 Re-Written URL 1: http://www.build99.com/flooringmain.php?maincatid=5&catname=Electricals
 Re-Written URL 2: http://www.build99.com/flooringmain1.php?catid=10&subname=Civil

.htaccess文件编写如下:

 Options +FollowSymLinks -MultiViews
 Options +SymLinksIfOwnerMatch
 RewriteEngine On

 RewriteBase /buildnin/
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-l
 RewriteCond %{REQUEST_FILENAME} !\.(pdf|js|ico|gif|jpg|jpeg|png|css|rar|zip|tar\.gz)$
 RewriteRule ^([^/]*)/([^/]*)$ /flooringmain.php?maincatid=$1&catname=$2 [L]
 RewriteRule ^([^/]*)/([^/]*)$ /flooringmain1.php?catid=$1&subname=$2 [L]

但是我们无法找到结果更正,请告诉我们上面的网址我们做错了什么?

1 个答案:

答案 0 :(得分:0)

完成..找到了它..

我更新了第二条规则的模式..刚刚使用了' - '在两种论证模式之间..它的工作很棒。

RewriteRule ^([^/]*)/([^/]*)$ /flooringmain.php?maincatid=$1&catname=$2 [L]
RewriteRule ^([^/]*)-([^/]*)$ /flooringmain1.php?catid=$1&subname=$2 [L]