Question

Here is my .htaccess file in public_html :

# Do not remove this line, otherwise mod_rewrite rules will stop working
RewriteBase /

DirectoryIndex /index.html

Redirect /index.html http://mysite.com/home.html

RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(?:jpeg|jpg|ico|svg|eot|woff|ttf|gif|bmp|png|tiff|css|js)$ [NC]
RewriteRule !^page/ page%{REQUEST_URI} [L,NC]

As you can see I set the website to load .html files from /page/. Unfortunately this method seems to be getting me in some trouble. First of all the favicon won't load (yes it is in the right place with proper href). I even added |ico| to that line of code in .htaccess. Any ideas on why jpgs etc. have no problem loading but the .ico fails?

Second, my site uses @fontface and i'm a little worried that .svg .eot .woff and .ttf font files might also fail due to the .htaccess trickery. I added those file extensions to the line of code in .htaccess but have no way of testing on various computers that might need the different font formats.

Was it helpful?

Solution

Try changing the condition to only fire the rules for your pages

RewriteEngine On
RewriteCond %{REQUEST_URI} \.(php|html?)$ [NC]
RewriteRule !^page/ page%{REQUEST_URI} [L,NC]

This is easier because you won't have to worry about all the different file types that could get wrongly redirected with your rule. To answer what's breaking your existing rule you would have to share your site's directory structure and the files' location.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top