Redirect almost all to index

Discuss practical ways rearrange URLs using mod_rewrite.

Redirect almost all to index

Postby jerkan » Tue Nov 04, 2008 5:02 am

Hi, I just want to redirect all requests to /index.html except some extensions.

These ones work:
/
/whatever

These ones load index.html but dont load js files properly (404 error):
/whatever/
/whatever/whichever

htacces file
Code: Select all
Options +FollowSymLinks
IndexIgnore */*

RewriteEngine On
RewriteRule !\.(js|html|xml|xsl|ico|gif|jpg|png|css|swf)$ index.html [NC,L]


Any help?
jerkan
 
Posts: 4
Joined: Fri Dec 22, 2006 5:10 am

Postby richardk » Tue Nov 04, 2008 10:38 am

Probably because of relative paths. FAQ: Relative paths to images, JavaScript, CSS and other external/linked files are broken.


Code: Select all
Options +FollowSymLinks -Indexes
IndexIgnore */*

RewriteEngine On

RewriteRule !\.(js|html|xml|xsl|ico|gif|jpg|png|css|swf)$ /index.html [NC,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby jerkan » Wed Nov 05, 2008 1:20 am

Yeah, I forgot to put <base> tag. My bad.

Thank you, richardk!
jerkan
 
Posts: 4
Joined: Fri Dec 22, 2006 5:10 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 20 guests

cron