views:

18

answers:

2

I want my htaccess to redirect URL that end on ".html" to the index.php, but not any other files (so images can keep their href and still be displayed)

This is how my htaccess looks like now, it works for the HTML redirect, but styles or images are not displayed (because they are also redirected, I guess)

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^/?([\w./]+)\.html$ /index.php?object=$1 [L]
RewriteRule ^/?([^html]+)$ /$1

How can I get it to work, so only .html-files are redirected?

+1  A: 
RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php

Used this before worked great.

Capt Otis
+1  A: 
RewriteRule ^/?([^html]+)$ /$1

Doesn't do what you want. It matches anything not containing any of the characters h, t, m or l. Your first rule is also strange; having both \w and . is redundant since . implies \w in addition to other characters.

Try this rule:

RewriteRule ^/?(.*)\.html$ /index.php?object=$1
adamse