Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other mod_rewrite fun Re: mod_rewrite fun

#114631
lhoezee
Member

Ok, apparently even though I checked the box for emails, I didn’t get the notification of your comment and I checked in spam, strange.

Give this a try:

**Note: ** This assumes the first ([^/]+) is an actual static file. so for example:

/about-us/test will actually be:
about-us.php?slug=test

and

/contact-us/test2 will actually be:
contact-us.php?slug=test2

If the file does not exists a 404 will be generated.



RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f

# Note: This will add a .php to the end of the slug value
# example:
# /about-us/test will actually be: /about-us?slug=test.php
RewriteRule ^(.*)$ $1.php
RewriteRule ^/index.php$ - [L]

RewriteRule ^([^/]+)/([^/]+) $1.php?slug=$2 [QSA,L]