![]() | | ||||||||
| | #1 |
| Active Warrior Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
|
I have a wordpress site that I would like to convert to a html site...and I would like to know how I could create the proper 301 redirect in .htacces so that all .php posts pages point to the new html pages, within the same domain. any suggestions would be very much appreciated. |
| | |
| | |
| | #2 |
| Advanced Warrior War Room Member Join Date: May 2004 Location: Perth, Australia.
Posts: 717
Thanks: 4
Thanked 182 Times in 138 Posts
|
Is there anything destinctive about the pages you wish to redirect. Are they anything like www.yourdomain.com?p=123 or are they broken up by categories etc. Its all depends on your permalink settings. Sorry i can't hep you more.. Bruce |
| ----------------- Get Your Backlinks indexed quicker at BackLinks2RSS Create Full Text Feeds from Partial RSS Feeds at FeedExpander.com. See the WarriorForum post about it here | |
| | |
| | #3 | |
| Active Warrior Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
| Quote:
I know that Host Gator has a redirect section , in which I once used to point a few stranded pages back to my site when I re-vamped one of my html sites...but it was only 2 pages that I needed to redirect... The idea I have for my current situation ( since my knowledge is limited in regards to htacces 301 redirects) would be to save all urls from the original site and then delete the word press files completely. Create and upload the new html files and then go to the redirect section in Hostgator and add each url from the old site individually to be repointed to the new html urls..... I suppose I could do this, but I have over 75 pages to redirect....I'm sure there is a more practical way , but I just don't know how to do it properly with a global 301 redirect code.... I have read quite a bit on 301 redirects before I posted this question, but it seems there are always details missing that I need, most of these guys don't explain things for the layman... anyway if all else fails, I'll try to do it the long way, but it would be nice if I could take care of the whole thing through .htaccess as there are other sites that I would like to convert as well... | |
| | ||
| | |
| | #4 |
| Senior Warrior Member War Room Member Join Date: Apr 2006 Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
|
Hi. I found a very practical resource for .htaccess and mod_rewrite that answers your question and many others about common usage situations. Here's the part that pertains to your question. This assumes that you want any arbitrary filename on your site the-post-name.php redirected to the-post-name.html. Put this in your .htaccess file: Code: Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^(.*).php$ /$1.html [R=301,L] |
| Executive I.T. consulting for small/medium business Website development | PHP - MySQL - JavaScript expert programming Software requirements analysis | Specification writing Project management | Vendor relationship management | |
| | |
| | #5 | |
| Active Warrior Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
| Quote:
sorry for the repetative questions ... I'm new to this stuff | |
| | ||
| | |
| | #6 | |
| Senior Warrior Member War Room Member Join Date: Apr 2006 Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
| Quote:
One, this assumes that for each valid URL you currently have that ends in .php, you're going to create an html file with the same name that will be accessible at the same URL except that it ends in .html. So if the following are currently valid URLs on your site:
You will be creating separate .html files which will be accessible with the following URLs:
Two, you don't want to add that code to your .htaccess file until after you've created and uploaded those html files and verified that the URLs work as expected. Steve | |
| Executive I.T. consulting for small/medium business Website development | PHP - MySQL - JavaScript expert programming Software requirements analysis | Specification writing Project management | Vendor relationship management | ||
| | |
| | #7 |
| Active Warrior Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
|
Thank you very much for that...I have spent many hours over the last few days trying to figure all this out... this is a really big help... thanks again !! |
| | |
| | |
| | #8 |
| Active Warrior Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
|
Hi Steve... I just thought of this...Would the redirects affect my back links to the site ? suppose my back links were pointing to mysite.com/post.php...would they still transfer over to the html version ? ...just curious One other question if I may, If I wanted to convert an html site to a Wordpress site, do I just switch around the .php with the .html ? Like this below: Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^(.*).html$ /$1.php [R=301,L] as opposed to this below: Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^(.*).php$ /$1.html [R=301,L] thanks for you help |
| | |
| | |
| | #9 |
| Senior Warrior Member War Room Member Join Date: Apr 2006 Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
|
Your backlinks will still work and will still count for SEO purposes. That's one of the best reasons for using 301 redirects in a case like this. Yes, you could go the other direction (from html to php) by rewriting the code like that. Steve |
| Executive I.T. consulting for small/medium business Website development | PHP - MySQL - JavaScript expert programming Software requirements analysis | Specification writing Project management | Vendor relationship management | |
| | |
| | #10 |
| Active Warrior Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
|
Thanks again, you have been a great help....
|
| | |
| | |
| | #11 |
| Active Warrior Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
|
Hi Steve, I did a test with the 301 redirect in .htaccess with an old blog that i don't use...I first uninstalled the wordpress theme through Fantastico and then proceeded to upload the new html files making sure that all html urls were identical to the old .php extensions...and then I uploaded the .htaccess file , but when when I did a test, I got a Server error 500 I rechecked to see if the .htaccess was good and I could find no errors ...so I don't know what happened...I'm using Host Gator so they support Apache...oh well I removed the .htaccess file from my directory and the new html version showed up from the serps... I'm glad I did a test on an unimportant site, otherwise, reconstructing my wordpress site would have been a real pain... anyway back to the drawing board for me |
| | |
| | |
| | #12 |
| Senior Warrior Member War Room Member Join Date: Apr 2006 Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
|
No, don't give up yet. There's something about that .htaccess code that Host Gator's configuration for mod_rewrite doesn't like. That's all error 500 means. It should be fixable. Let me try an experiment and get back to you. Steve |
| Executive I.T. consulting for small/medium business Website development | PHP - MySQL - JavaScript expert programming Software requirements analysis | Specification writing Project management | Vendor relationship management | |
| | |
| | #13 |
| Active Warrior Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
|
I really appreciate all your help..
|
| | |
| | |
| | #14 |
| Senior Warrior Member War Room Member Join Date: Apr 2006 Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
|
Well, it works perfectly on one of my Host Gator sites. Is your .htaccess file in your public_html folder? Is this the only content in your .htaccess file? (You say you checked it, but did you copy and paste it?) Code: Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteRule ^(.*).php$ /$1.html [R=301,L] Steve |
| Executive I.T. consulting for small/medium business Website development | PHP - MySQL - JavaScript expert programming Software requirements analysis | Specification writing Project management | Vendor relationship management | |
| | |
| | #15 |
| Active Warrior Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
|
Hi Steve, I figured it out.... There were 2 errors on my part, first of all I had saved the .htaccess file under txt. and not under "All Files" from my note pad... 2nd mistake was that my file extensions are htm and not html....for some reason my default settings in Dream Weaver were set to htm. which I don't normally do...but I just whipped up a quick template to make my test with...I just switched the html to htm in the redirect code..and everything works like a charm ! I just wish those guys in the Google webmaster forum were as helpful as you were...my questions were totally ignored over there.. Again I must thank you one more time, because of your help , I just made a huge advancement with what I needed to do take care and have a great day ! |
| | |
| | |
| | #16 |
| Senior Warrior Member War Room Member Join Date: Apr 2006 Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
|
That's really great! I'm glad you got it straightened out. Steve |
| Executive I.T. consulting for small/medium business Website development | PHP - MySQL - JavaScript expert programming Software requirements analysis | Specification writing Project management | Vendor relationship management | |
| | |
![]() |
|
| Tags |
| 301, question, redirects |
| Thread Tools | |
| |
![]() |