0

I got the following modrewrite script:

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

The whole .htaccess file:

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

Can someone explain me what i am doing wrong for the Categories pages?

Rens Tillmann
  • 474
  • 2
  • 7
  • 21

2 Answers2

0

Not sure why the 2nd one isn't working for you, I had problems with it when testing on my apache setup. But the following works for me:

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]

Just tweaked the regex and added the [L] flag.

Jon Lin
  • 142,182
  • 29
  • 220
  • 220
0

Thanks for your answer, but it didn't worked for me, this code below worked for me:

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}

Now the $_GET method also works for the categorie.php pages. Now I can use $_GET['categorie_url'] to retrieve the current categorie form the database.

Rens Tillmann
  • 474
  • 2
  • 7
  • 21