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

Reply
 
LinkBack Thread Tools
Old 07-24-2009, 11:43 AM   #1
Buy @ DomainShoe.com
War Room Member
 
legitimatefreestuff's Avatar
 
Join Date: Mar 2008
Location: Texas, United States
Posts: 89
Blog Entries: 6
Thanks: 28
Thanked 4 Times in 4 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Default 301 redirect for subfolder question

I'm able to redirect for the main page using this code:


RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

However, the same conditions don't apply for a subfolder as I can't get http://domain.com/blog to redirect to http://www.domain.com/blog.

Anyone know how to redirect for this subfolder?

Thank You.

DomainShoe.com = $7.49 .nets, $6.99 .orgs, $1.95 privacy. Free whois privacy with purchase of 5 domains. Make Money Reselling Domains
legitimatefreestuff is offline   Reply With Quote
Old 07-24-2009, 02:36 PM   #2
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: 301 redirect for subfolder question

Change your code to this:
Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
That should do it. This version tells it to make sure it matches all the way to the end of the URL. Your original didn't.

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 07-24-2009, 02:54 PM   #3
Buy @ DomainShoe.com
War Room Member
 
legitimatefreestuff's Avatar
 
Join Date: Mar 2008
Location: Texas, United States
Posts: 89
Blog Entries: 6
Thanks: 28
Thanked 4 Times in 4 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Default Re: 301 redirect for subfolder question

Thank you very much, Steve. That did work for me.

Do you know the code for a regular URL redirect on WP?

DomainShoe.com = $7.49 .nets, $6.99 .orgs, $1.95 privacy. Free whois privacy with purchase of 5 domains. Make Money Reselling Domains
legitimatefreestuff is offline   Reply With Quote
Old 07-24-2009, 06:58 PM   #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: 301 redirect for subfolder question

Quote:
Originally Posted by legitimatefreestuff View Post
Do you know the code for a regular URL redirect on WP?
I'm not sure what you mean by this. Please explain and give an example.

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 07-27-2009, 03:57 PM   #5
Buy @ DomainShoe.com
War Room Member
 
legitimatefreestuff's Avatar
 
Join Date: Mar 2008
Location: Texas, United States
Posts: 89
Blog Entries: 6
Thanks: 28
Thanked 4 Times in 4 Posts
Social Networking View Member's FaceBook Profile  View Member's Twitter Profile  View Member's YouTube Profile
Default Re: 301 redirect for subfolder question

Quote:
Originally Posted by Steve Diamond View Post
I'm not sure what you mean by this. Please explain and give an example.

Steve
Just the same as I mentioned in my first post but for WP

Example:

redirecting http:// wordpressblog.com to http:// www.wordpressblog .com.

Inserting a .htaccess doesn't do the trick in a WP blog for me.

DomainShoe.com = $7.49 .nets, $6.99 .orgs, $1.95 privacy. Free whois privacy with purchase of 5 domains. Make Money Reselling Domains
legitimatefreestuff is offline   Reply With Quote
Old 07-27-2009, 08:06 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: 301 redirect for subfolder question

This should be a complete solution for WordPress. Just make sure that this code comes before the WP-generated code in your .htaccess file.

Code:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [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
Reply

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

Tags
301, question, redirect, subfolder

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 02:50 AM.