Dynadot โ€” .com Registration $8.99

.htaccess redirect

Spaceship Spaceship
Watch

SiKing

Registered MemberEstablished Member
Impact
6
Hey. I would be very grateful if someone could help me with the following; I have a series of PHP files which I would like accessible as .html (e.g. index.html actually points to index.php). However, when trying to view fckeditor.html file, it's looking for fckeditor.php (and presents a "300 multiple choices" Bullcrap). Until switching to 1and1.co.uk hosting, it worked fine. Here is the .htaccess:

Code:
ErrorDocument 404 /404-page-not-found.html
#AddType application/x-httpd-php .php .php3 .phtml .html
AddType x-mapp-php4 .html

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*).html /$1.php [QSA,L]

The line causing the trouble is:

Code:
RewriteRule (.*).html /$1.php [QSA,L]

UPDATE: I think it may instead be the line:
Code:
RewriteCond %{SCRIPT_FILENAME} !-f
..not working. Surely, if the file doesn't exist, THEN do the rewrite. No?
Many thanks
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
You can try this :)
Code:
RewriteEngine On

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*).html $1.php [QSA,L]
 
0
•••
Thanks but now PHP files do not run with .html.

Just some advice: do not choose 1and1 for web hosting
 
0
•••
Greetings.

You can configure your apache to process php in .html files a much easier way than using rewrites and .htaccess

Just edit your config file for the php apache module and add .html to the end of the line. Here is an example.

Code:
AddType application/x-httpd-php .php .phtml .php3 .html

The file is usually called
Code:
php.conf
and is located in your apache directory.

Regards,
Richard.
 
0
•••
Hi Richard. Thanks for your help and welcome to Namepros.

I think this will be the likely solution (using the .htaccess though and not the conf file). The problem is; with 1and1, you have to use an alternate method which is a bit of a snag:

Code:
AddType x-mapp-php4 .html

But using this method would mean I'd have to rename all my current .php files to .html
 
0
•••
Perhaps I did not understand what you wanted to do. I thought you wanted to execute PHP from .html files ?

If you want your .php to be used as .html, then rename them to .html and 301 the old .php to the .html and you're done. Keep it simple and don't confuse the user or the SE's.

- Richard
 
0
•••
Unstoppable Domains
Domain Recover
DomainEasy โ€” Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back