Jump to content

Need to make a php file into an html file, than redirect? not working


sw0o0sh

Recommended Posts

It's probably not working either since I'm a newb, lol. But I was going through this tutorial.

Basically, my real website files are .php files. I want them to be viewed as .html files, and with an external redirect from .php to .html

I was going through this tutorial, but it doesnt seem to work appropriately.

 

RewriteRule ^(.*)\.html$ $1.php [NC]

That was basically allowing my php files to be viewable as html files, though the real php version could still be viewed.

 

Then when I added

 

RewriteRule ^(.+)\.php$ http://urlexample.com/$1.html [R=301,NC]

It redirects the .php to the .html, but then says the .html doesn't exist. Even though on the previous line it allowed .php to be viewed as .html..

 

What am I doing wrong?

I'm surprised you don't get a 500 server error since you're essentially creating a loop between php > HTML > php. IMO the best option would be to simply rename all the files to .html, and make Apache parse HTML files as php scripts by using...

 

AddType application/x-httpd-php .html

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.