views:

21

answers:

2

How can I get anything but files to rewrite to index.php's params? I'm using apache, mod_rewrite, etc.

A: 

Try this:

RewriteRule /([^/]*)/([^/]*)/([^/]*)[^\.].*  /index.php?var1=$1&var2=$2&var3=$3 [R=301]

This will redirect url like /foo/bar/baz to /index.php?var1=foo&var2=bar&var3=baz

jcubic
A: 

If you want to rewrite anything that isn't a request for a regular file I'd use this:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{DOCUMENT_ROOT}/index\.php -f
    RewriteRule ^(.*)$  /index.php?page=$1 [QSA]
</IfModule>

This way you don't need to concern yourself about adhering to a certain URL format for your rewrites - you can test and act accordingly in your serving script.

Nev Stokes