johny long
johny long

Reputation: 67

mod_rewrite - rewrite directory to query string except /#!/

I'm trying to rewrite www.domain.com/something/some/ to www.domain.com/index.php?q=something/some/

This is what I have so far:

RewriteCond %{REQUEST_FILENAME} ([a-z-]+)/?$
RewriteRule (.*) index.php?q=$1 [QSA,L]

But I want to exclude urls like these: www.domain.com/#!/something

Could you please help?

Thanks, John

Upvotes: 1

Views: 219

Answers (1)

anubhava
anubhava

Reputation: 785551

You can use this rule in root .htaccess:

RewriteEngine On

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

Use of .+ also takes care of /#!/something since Apache will only get / for that as text after # doesn't reach web server.

Upvotes: 2

Related Questions