MODx .htaccess rewrite

Topics: User Forum
Sep 23, 2007 at 12:37 PM
Hello,

Im trying to rewrite the .htaccess of MODx (http://modxcms.com/) to a Ionics Isapi Rewrite .ini to get SEO friendly urls but so far it just wont work.

Ive tried this:

RewriteBase /subdomain

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 L,QSA

This should make it like this: subdomain.maindomain.com/test.html > subdomain.maindomain.com/index.php?q=test.html

But unfortunatly it wont work (doesnt do anything). Ive tried to search the readme but still nothing. Does somebody have an idea on how to do this?? Maybe other MODx users need this info too..

Thanks in advance,
S4nder


Oct 7, 2007 at 10:46 AM
BUMP anybody?
Oct 9, 2008 at 12:13 AM
I ran into a similar issue myself. The problem is that the filter doesn't understand the QSA modifier, which appends the query string of the input URL to the output URL, so the url
/what/ever?query=string

would map to
/index.php?q=/what/ever&query=string

instead of
/index.php?q=/what/ever?query=string

However, this can be worked around by adding a second rule. Here's what worked for me:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^(.*)$ /index.php?q=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\?(.*)$ /index.php?q=$1&$2 [L]

Coordinator
Oct 14, 2008 at 4:02 AM
Thanks for that - good tip.
Coordinator
Aug 14, 2009 at 3:09 PM

just a quick note - QSA is now supported by IIRF.