我想更改此网址
domain.com/adsbycat/sub_category.php?category=car-and-buses&category_id=1&sub_category=Car
到
domain.com/car-and-buses/1/Car
我写这段代码来做这件事
RewriteEngine On
RewriteBase /domain.com/
RewriteRule ^adsbycat/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$ adsbycat/sub_category.php?category=$1&category_id=$2&sub_category=$3
但是当我请求新网址时,它显示 404 not found 。请修改此代码。
答案 0 :(得分:2)
在网站根.htaccess中使用此规则重写domain.com/car-and-buses/1/Car
:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/[^/]+/(.+)$ adsbycat/sub_category.php?category=$1&category_id=$2&sub_category=$3 [NC,L,QSA]