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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.