Byron Posted May 22, 2010 Posted May 22, 2010 Ok, I searched "Google" and find that there is a way to redirect (301) pages of .html to .php using .htaccess ( http://www.isitebuild.com/301-redirect.htm ), do this work? (If Yes, I think I would change all My files extension to .php and use this .htaccess code) RewriteEngine on RewriteBase / RewriteRule (.*).html$ /$1.php That would work but that's going to redirect ANY .html request to the .php version. Do you really want ALL .html request redirected? Are you depeding on your Google rankings to make you any money? If your not, then I would just change all of the extensions (if that's what you really want to do) and not redirect at all. I myself would probably just go with the .htaccess, but it's totally up to you what you want to do.
Tony M Posted May 22, 2010 Author Posted May 22, 2010 Ok, I searched "Google" and find that there is a way to redirect (301) pages of .html to .php using .htaccess ( http://www.isitebuild.com/301-redirect.htm ), do this work? (If Yes, I think I would change all My files extension to .php and use this .htaccess code) That would work but that's going to redirect ANY .html request to the .php version. Do you really want ALL .html request redirected? Are you depeding on your Google rankings to make you any money? If your not, then I would just change all of the extensions (if that's what you really want to do) and not redirect at all. I myself would probably just go with the .htaccess, but it's totally up to you what you want to do. (I do not want any money from My website, I only want things to work) Thanks for Your Help, Ok I will use the code that You showed Me at "Post #14" AddHandler application/x-httpd-php5 .html .htm (in .htaccess) (If I experience some errors in this code, I will re-post the problem)
Ashoat Posted May 24, 2010 Posted May 24, 2010 For the purpose of simple includes, I would recommend SSI. It handles exactly what you're looking for, without much overhead.
Tony M Posted May 24, 2010 Author Posted May 24, 2010 I would recommend SSI. It handles exactly what you're looking for, without much overhead. I have this last question : When using SSI , do I need to change My files extension to .php or it will work even if the extensions still .html ?
Wizard Posted May 24, 2010 Posted May 24, 2010 I would recommend SSI. It handles exactly what you're looking for, without much overhead. I have this last question : When using SSI , do I need to change My files extension to .php or it will work even if the extensions still .html ? .shtml There's a tutorial teaching SSI on the bottom of that Wikipedia article.
Byron Posted May 24, 2010 Posted May 24, 2010 You also have two other options that will allow you to keep the .html extension with SSI. Option 1. Add this to your .htaccess file: AddHandler server-parsed .html Option 2. Add this to your .htaccess file: XBitHack on and chmod your html files that have SSI to 744.
Byron Posted May 25, 2010 Posted May 25, 2010 Tony here's a script I wrote that uses the php rename function. You can run this php script inside each of your directories. What it does is look for any file that ends in .html and will rename it to .php or .shtml dependng on what you choose to do. <?php if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if ( preg_match("#(\.html)$#i", $file) ) { $extract = pathinfo($file); $ext = ($extract['basename']); $fn = ($extract['filename']); # to rename to php uncomment line below # rename("$file", "$fn.php"); # to rename to .shtml uncomment line below # rename("$file", "$fn.shtml"); echo "Renamed: $file<br>"; } } } closedir($handle); } ?> That should make it allot easier to rename ALL html files in a directory if you choose to go that route.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now