我在我的htaccess中使用此代码:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^category/([^/]*)/([^/]*)$ /index.php?type=category&category=$1&subcategory=$2 [L]
但如果我输入此网址:
domain.com/category/example-category
它有404错误。我必须输入网址:
domain.com/category/example-category/sub-category-example
我想要输入网址:
domain.com/category/example-category
重写为
domain.com/index.php?type=category&category=example-category
没有404错误
如果输入
domain.com/category/example-category/sub-category-example
重写为
domain.com/index.php?type=category&category=example-category&subcategory=sub-category-example
答案 0 :(得分:0)
尝试添加此内容:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^category/([^/]*)/?$ /index.php?type=category&category=$1 [L]