2012-05-28 39 views
0

我得到了以下modrewrite腳本:Modrewrite的產品頁面的工作,但對於categorie頁面不

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 

有人可以解釋我什麼我做錯了分類頁面?

回答

0

不知道爲什麼第二個不適合你,在測試我的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]標誌。

0

謝謝您的回答,但它並沒有工作對我來說,這下面的代碼爲我工作:

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} 

現在$ _ GET方法也適用於在categorie.php頁面。 現在我可以使用$ _GET ['categorie_url']從數據庫中檢索當前類別。