.htaccess Modrewrite适用于产品页面,但不适用于分类页面

.htaccess Modrewrite适用于产品页面,但不适用于分类页面,.htaccess,mod-rewrite,seo,friendly-url,.htaccess,Mod Rewrite,Seo,Friendly Url,我得到了以下modrewrite脚本: RewriteCond %{ENV:space_replacer} !^$ RewriteRule ^.*$ %{ENV:space_replacer} RewriteRule (.*)/(.*)$ product.php?categorie_url=$1&product_url=$2 THIS ONE ABOVE IS WORKING: -> domain.com/korsetten/school-girl RewriteCond

我得到了以下modrewrite脚本:

RewriteCond %{ENV:space_replacer} !^$ 
RewriteRule ^.*$ %{ENV:space_replacer} 
RewriteRule (.*)/(.*)$ product.php?categorie_url=$1&product_url=$2

THIS ONE ABOVE IS WORKING: -> domain.com/korsetten/school-girl


RewriteCond %{ENV:space_replacer} !^$ 
RewriteRule ^.*$ %{ENV:space_replacer} 
RewriteRule (.*)$ categorie.php?categorie_url=$1

THIS ONE ABOVE IS NOT WORKING: -> domain.com/korsetten
整个.htaccess文件:

RewriteEngine on 

RewriteCond %{ENV:space_replacer} !^$ 
RewriteRule ^.*$ %{ENV:space_replacer} 
RewriteRule (.*)/(.*)$ product.php?categorie_url=$1&product_url=$2  

RewriteCond %{ENV:space_replacer} !^$ 
RewriteRule ^.*$ %{ENV:space_replacer} 
RewriteRule (.*)$ categorie.php?categorie_url=$1

有人能解释一下我在分类页面上做错了什么吗?

不确定为什么第二个页面不适合您,我在apache设置上测试时遇到了问题。但以下几点对我有用:

RewriteCond %{ENV:space_replacer} !^$
RewriteRule ^.*$ %{ENV:space_replacer}
RewriteRule ^([^/]+)/([^/]+)$ product.php?categorie_url=$1&product_url=$2  [L]

RewriteCond %{ENV:space_replacer} !^$
RewriteRule ^.*$ %{ENV:space_replacer}
RewriteRule ^([^/]+)/?$ categorie.php?categorie_url=$1  [L]

刚刚调整了正则表达式并添加了
[L]
标志。

谢谢你的回答,但它对我不起作用,下面的代码对我起作用:

RewriteCond %{REQUEST_URI} ^(.*)\ (.*)$ 
RewriteRule ^.*$ %1-%2 [E=space_replacer:%1-%2] 
RewriteCond %{ENV:space_replacer} !^$ 
RewriteCond %{ENV:space_replacer} !^.*\ .*$ 

RewriteRule ^.*$ %{ENV:space_replacer} [R=301,L] 
RewriteRule (.*)$ categorie.php?categorie_url=$1&%{QUERY_STRING}
RewriteRule (.*)/(.*)$ products.php?categorie_url=$1&product_url=$2&%{QUERY_STRING}
现在$\u GET方法也适用于categorie.php页面。 现在我可以使用$\u GET['categie\u url']从数据库中检索当前的分类