Matt Fiddles

Life's so vast, there's just so much to do...

User Tools

Site Tools


"The young man knows the rules, but the old man knows the exceptions."

Where will you go today?

"`You know they've reintroduced the death penalty for insurance company directors?'
`Really?' said Arthur. `No I didn't. For what offence?'
Trillian frowned.
`What do you mean, offence?'
`I see.'"

- Evidence that there will be some justice in the Universe eventually.

Apache mod_rewrite Tips

Some other tips are here

Query Strings

Rewrite Query Strings

Capture Query Strings

Apache .htaccess query string redirects

Note: $1 is for paths, %1 is for query strings (mostly)

Remove Query

RewriteCond %{REQUEST_URI} /page [NC]
RewriteRule ^(.*)$ /%1? [R=301,L]


RewriteCond %{QUERY_STRING} id=(.*) [NC]
RewriteRule ^(.*)$ /$1/%1 [R=301,L]


Replace Characters

Replace : with /.

RewriteRule ^(.*):(.*)$ $1/$2 [R=301,L]
computers/websites/apache-mod_rewrite.txt · Last modified: May 28, 2014 (4 years ago) by Matt Bagley