.htaccess redirects

Is there a script or code to redirect all htm and/or html files to php files without having to redirect every individual file?

Most of the examples I have found don’t seem to work and either put the site into a permanent loop or shows a 404.

Thank you

Gary

Try this


RewriteEngine On
RewriteRule ^(.*)\\.html?$ $1.php [L]

:slight_smile:

ScallioXTX

Thank you for your reply. I had tried that one, and also just tried it again, and I got a 404. I had tried in both the root and in the public_html folder where the web files are.

Am I doing something wrong?

Thank you again for your reply.

Gary

Are you sure the server is Apache, supports .htaccess files, has mod_rewrite installed and allows you to use mod_rewrite?
If that very simple rewrite doesn’t work I’d say the answer to one of questions above is no.
You’d probably better contact your host and ask.

I had / have an .htaccess file on there now that list all of the redirect pages individually that was working (I say was, when I tried the change things seem to have fallen apart and I have not gotten back into it to see what the issue was).

The code I used that worked is


Redirect 301 /BecomeADealer.html http://www.acomwholesale.com/become.php

I have this in the public_html folder, not in the root directory.

Gary

Ah yes I meant public_html. Since those have different names across hosters (some name it htdocs or html) I refer to them as the root directory.

Anyway, the Redirect shows that you have Apache, and .htaccess files work.
But, Redirect is not a part of mod_rewrite (but rather of the Apache core; it can’t be disabled), which leads me to believe mod_rewrite is not supported by your host.