niksos
niksos

Reputation: 433

Redirect everything to index (with htaccess and without messing images)

How can I redirect everything to index page (like www.domain.com/anything) without messing up the css, img and js loading on this page?

Should this work?

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/index.html
RewriteCond $1 !^(img|css|js|font)
RewriteRule ^(.*)$ /index.html [L,R=301]

Upvotes: 0

Views: 35

Answers (1)

Jenne
Jenne

Reputation: 893

I tend to use:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [QSA,L]

Where the RewriteCond -f will match any regular file calls (which are negated with the !). So you can call those normally and anything else (incl 404) are sent to the index.

Upvotes: 2

Related Questions