Reputation: 15217
I'm not very experienced with .htaccess
related stuff, I was looking to get some help. Basically what I'm trying to do is this:
Any request that looks like this (example):
/foo.html
Would be rewrote to:
/foo
And any request that is a static file, I'd like it serve:
/index.html
Does that make sense? Any idea how to do this?
Here's what I have so far, though it's not correct as far as I know:
RewriteRule %{REQUEST_FILENAME} !-d
RewriteRule %{REQUEST_FILENAME} -f
RewriteCond ^(.*)$ $1.html [NC,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(.*) /index.html [NC,L]
Upvotes: 0
Views: 109
Reputation: 786091
Check for existence of .html
file before adding it to URIs:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteCond %{REQUEST_FILENAME}.html -f [NC]
RewriteRule ^(.*)$ $1.html [L]
RewriteRule . /index.html [L]
Upvotes: 1