Take the 2-minute tour ×

Currently, my .htaccess file looks like htis:

IndexIgnore */*
RewriteEngine on
RewriteRule ^add /add.php
RewriteRule ^add/$ add.php
RewriteRule ^sitemap.xml /xmlsitemap.php
RewriteRule ^([^/\.]+)$ /index.php?slug=$1
RewriteRule ^([^/\.]+)/$ /index.php?slug=$1

It works fine for links as: site.com/category/

However, i would like the complete slug after site.com/. So that i can redirect site.com/category1/subcategory2/subsubcategory3 etc. There can be an unknown amount of subcategories inside a category.

I tried with request_uri but that didn't really work out.

How to do this? Thanks a bunch!

share|improve this question

2 Answers 2


RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* slug.php?%{QUERY_STRING} [L]

this will pass URL to slug.php

share|improve this answer
thx! however, if i do that, i get: domain.com/index.php?slug=index.php –  Maurice Kroon Jun 26 '09 at 9:28
thx again.. it stays in the url now yes. but... it gives me a 500 internal server error when i set something behind domain.com/. domain.com works however, if i use domain.com/category it doesn't –  Maurice Kroon Jun 26 '09 at 9:51
up vote 0 down vote accepted

ok, got it. it's simply: deleting the ^/. from the regex. i just figured that means that it has to stop at any / :) but... thx! it works now! :)

share|improve this answer

Your Answer


