Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 08-13-2009, 08:18 PM   #1
Active Warrior
 
Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
Default Have a question on 301 redirects

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.

pts123 is offline   Reply With Quote
Old 08-14-2009, 02:17 AM   #2
Advanced Warrior
War Room Member
 
Bruce Hearder's Avatar
 
Join Date: May 2004
Location: Perth, Australia.
Posts: 717
Thanks: 4
Thanked 182 Times in 138 Posts
Social Networking View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to Bruce Hearder
Default Re: Have a question on 301 redirects

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
Bruce Hearder is offline   Reply With Quote
Old 08-14-2009, 07:32 AM   #3
Active Warrior
 
Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
Default Re: Have a question on 301 redirects

Quote:
Originally Posted by Bruce Hearder View Post
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
There are no categories, just a series of post pages permalink structure is %postname%.php....

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

pts123 is offline   Reply With Quote
Old 08-14-2009, 08:45 AM   #4
Senior Warrior Member
War Room Member
 
Steve Diamond's Avatar
 
Join Date: Apr 2006
Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to Steve Diamond
Default Re: Have a question on 301 redirects

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]
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
Steve Diamond is offline   Reply With Quote
Old 08-14-2009, 09:47 AM   #5
Active Warrior
 
Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
Default Re: Have a question on 301 redirects

Quote:
Originally Posted by Steve Diamond View Post
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]
Steve
Hey Thanks for that ! So that is all I have to put in the .htaccsess ? and that will take care of everything ?

sorry for the repetative questions ... I'm new to this stuff

pts123 is offline   Reply With Quote
Old 08-14-2009, 01:08 PM   #6
Senior Warrior Member
War Room Member
 
Steve Diamond's Avatar
 
Join Date: Apr 2006
Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to Steve Diamond
Default Re: Have a question on 301 redirects

Quote:
Originally Posted by pts123 View Post
Hey Thanks for that ! So that is all I have to put in the .htaccsess ? and that will take care of everything ?

sorry for the repetative questions ... I'm new to this stuff
Yes, that's it. Now, let me add a few details, since you are new to this.

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:
  • http://www.yourdomain.com/post-name-one.php
  • http://www.yourdomain.com/post-name-two.php
  • http://www.yourdomain.com/post-name-three.php

You will be creating separate .html files which will be accessible with the following URLs:
  • http://www.yourdomain.com/post-name-one.html
  • http://www.yourdomain.com/post-name-two.html
  • http://www.yourdomain.com/post-name-three.html

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
Steve Diamond is offline   Reply With Quote
Old 08-14-2009, 01:12 PM   #7
Active Warrior
 
Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
Default Re: Have a question on 301 redirects

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 !!

pts123 is offline   Reply With Quote
Old 08-15-2009, 07:30 AM   #8
Active Warrior
 
Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
Default Re: Have a question on 301 redirects

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

pts123 is offline   Reply With Quote
Old 08-15-2009, 09:35 AM   #9
Senior Warrior Member
War Room Member
 
Steve Diamond's Avatar
 
Join Date: Apr 2006
Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to Steve Diamond
Default Re: Have a question on 301 redirects

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
Steve Diamond is offline   Reply With Quote
Old 08-15-2009, 10:49 AM   #10
Active Warrior
 
Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
Default Re: Have a question on 301 redirects

Thanks again, you have been a great help....

pts123 is offline   Reply With Quote
Old 08-15-2009, 12:45 PM   #11
Active Warrior
 
Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
Default Re: Have a question on 301 redirects

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

pts123 is offline   Reply With Quote
Old 08-15-2009, 02:46 PM   #12
Senior Warrior Member
War Room Member
 
Steve Diamond's Avatar
 
Join Date: Apr 2006
Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to Steve Diamond
Default Re: Have a question on 301 redirects

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
Steve Diamond is offline   Reply With Quote
Old 08-15-2009, 03:06 PM   #13
Active Warrior
 
Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
Default Re: Have a question on 301 redirects

I really appreciate all your help..

pts123 is offline   Reply With Quote
Old 08-15-2009, 03:10 PM   #14
Senior Warrior Member
War Room Member
 
Steve Diamond's Avatar
 
Join Date: Apr 2006
Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to Steve Diamond
Default Re: Have a question on 301 redirects

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]
If so, I can't explain why your Host Gator account should behave any differently from mine. I'd advise contacting Host Gator support.

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
Steve Diamond is offline   Reply With Quote
Old 08-15-2009, 04:50 PM   #15
Active Warrior
 
Join Date: Jun 2009
Posts: 67
Thanks: 1
Thanked 1 Time in 1 Post
Default Re: Have a question on 301 redirects

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 !

pts123 is offline   Reply With Quote
Old 08-15-2009, 06:04 PM   #16
Senior Warrior Member
War Room Member
 
Steve Diamond's Avatar
 
Join Date: Apr 2006
Location: Tucson, AZ, USA.
Posts: 1,025
Thanks: 120
Thanked 158 Times in 115 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to Steve Diamond
Default Re: Have a question on 301 redirects

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
Steve Diamond is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Tags
301, question, redirects

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 03:50 AM.