SEO Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   SEO Chat ForumsOtherSEO Scripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread SEO Chat Forums Sponsor:
  #1  
Old January 15th, 2008, 12:48 AM
andrenym00 andrenym00 is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 61 andrenym00 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 36 m 2 sec
Reputation Power: 4
301 redirect help

I have this placed in my .htaccess file:

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^blahblah.com [nc]
rewriterule ^(.*)$ http://www.blahblah.com/$1 [r=301,nc]


To convert all non www pages. I also have an index.php file I would like to redirect to my home page. Any offer some advice on how to do?

Last edited by andrenym00 : January 15th, 2008 at 12:49 AM. Reason: Didn't want to show my domain

Reply With Quote
  #2  
Old January 15th, 2008, 12:57 AM
pro_seo's Avatar
pro_seo pro_seo is offline
Moderator
SEO Chat Frequenter (2500 - 2999 posts)
 
Join Date: Apr 2006
Location: I N D I A
Posts: 2,902 pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 6 Days 5 h 33 m 12 sec
Reputation Power: 40
Send a message via MSN to pro_seo Send a message via Yahoo to pro_seo Send a message via Google Talk to pro_seo Send a message via Skype to pro_seo
Use this one:

Quote:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
__________________

SEO FAQs - You might find your answer here.
SEOchat Forum Rules - Read Before You Post


**Do what you feel in your heart to be right- for you'll be criticized anyway. You'll be damned if you do, and damned if you don't.**

Reply With Quote
  #3  
Old January 15th, 2008, 01:03 AM
andrenym00 andrenym00 is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 61 andrenym00 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 36 m 2 sec
Reputation Power: 4
Ok, it worked for http://www.blahblah.com/index.php, but not for http://blahblah.com/index.php . Does it matter?

Reply With Quote
  #4  
Old January 15th, 2008, 01:11 AM
andrenym00 andrenym00 is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 61 andrenym00 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 36 m 2 sec
Reputation Power: 4
for example if i use http://blahblah.com/index.php it redirects to http://www.blahblah.com/http://www.blahblah.com/

Reply With Quote
  #5  
Old January 15th, 2008, 01:33 AM
pro_seo's Avatar
pro_seo pro_seo is offline
Moderator
SEO Chat Frequenter (2500 - 2999 posts)
 
Join Date: Apr 2006
Location: I N D I A
Posts: 2,902 pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 6 Days 5 h 33 m 12 sec
Reputation Power: 40
Send a message via MSN to pro_seo Send a message via Yahoo to pro_seo Send a message via Google Talk to pro_seo Send a message via Skype to pro_seo
Quote:
Ok, it worked for http://www.blahblah.com/index.php, but not for http://blahblah.com/index.php . Does it matter?


It should work for both!

If you request for http://blahblah.com/index.php it will first redirect to http://www.blahblah.com/index.php and then this will again redirect to http://www.blahblah.com/
Comments on this post
andrenym00 agrees: thx

Reply With Quote
  #6  
Old January 15th, 2008, 01:47 AM
andrenym00 andrenym00 is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 61 andrenym00 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 36 m 2 sec
Reputation Power: 4
Quote:
Originally Posted by pro_seo
Use this one:


thx for help i modified it a bit :

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]

Using these together and will redirect index.php to main page no matter if its non www or www.

thx for help I hope this is SEO Friendly?

Last edited by andrenym00 : January 15th, 2008 at 01:51 AM. Reason: privacy

Reply With Quote
  #7  
Old January 15th, 2008, 01:52 AM
andrenym00 andrenym00 is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 61 andrenym00 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 36 m 2 sec
Reputation Power: 4
Quote:
Originally Posted by pro_seo
It should work for both!

If you request for http://blahblah.com/index.php it will first redirect to http://www.blahblah.com/index.php and then this will again redirect to http://www.blahblah.com/



for some reason it didn't.

Reply With Quote
  #8  
Old January 15th, 2008, 02:58 AM
pro_seo's Avatar
pro_seo pro_seo is offline
Moderator
SEO Chat Frequenter (2500 - 2999 posts)
 
Join Date: Apr 2006
Location: I N D I A
Posts: 2,902 pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 6 Days 5 h 33 m 12 sec
Reputation Power: 40
Send a message via MSN to pro_seo Send a message via Yahoo to pro_seo Send a message via Google Talk to pro_seo Send a message via Skype to pro_seo
Quote:
Originally Posted by andrenym00
thx for help i modified it a bit :

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]

Using these together and will redirect index.php to main page no matter if its non www or www.

thx for help I hope this is SEO Friendly?



You don't need to put rewriteEngine on for each code, you just need to put it once to turn the engine on.

So finally your htaccess should look like:

Code:
Options +FollowSymlinks
RewriteEngine on

rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
RewriteRule ^(.*)index\.php$ /$1 [R=301,L] 

Last edited by pro_seo : January 15th, 2008 at 03:01 AM. Reason: updated code

Reply With Quote
  #9  
Old January 15th, 2008, 04:41 AM
lovekills_s's Avatar
lovekills_s lovekills_s is offline
The Outstanding Red Apple
SEO Chat Regular (2000 - 2499 posts)
 
Join Date: Apr 2006
Posts: 2,465 lovekills_s User rank is Sergeant Major (2000 - 5000 Reputation Level)lovekills_s User rank is Sergeant Major (2000 - 5000 Reputation Level)lovekills_s User rank is Sergeant Major (2000 - 5000 Reputation Level)lovekills_s User rank is Sergeant Major (2000 - 5000 Reputation Level)lovekills_s User rank is Sergeant Major (2000 - 5000 Reputation Level)lovekills_s User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 4 Days 5 h 44 m 51 sec
Reputation Power: 31
Send a message via AIM to lovekills_s Send a message via MSN to lovekills_s Send a message via Yahoo to lovekills_s Send a message via Google Talk to lovekills_s Send a message via Skype to lovekills_s
MySpace
Quote:
for some reason it didn't.


The reverse 301 Redirect i.e from index.php to www.domain.com/ could result in LOOP, which would not work.. so be carefull...

And infact that hardly matters..
__________________
Link Diary - Build Links Fast & Easy. Similar to Linkmarket, with option of three way link exchange and anchor rotation.

**"Save SEO Industry - GO VIRAL!! - Tips and Tricks ."**
**"If you surrender to the wind, you can ride it."**
**"AdSlots Available - PM me for more Info on Website and its Stats - Pfft! The Website is for Sale! - Contact Me"

Reply With Quote
  #10  
Old January 15th, 2008, 05:20 AM
pro_seo's Avatar
pro_seo pro_seo is offline
Moderator
SEO Chat Frequenter (2500 - 2999 posts)
 
Join Date: Apr 2006
Location: I N D I A
Posts: 2,902 pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level)pro_seo User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 6 Days 5 h 33 m 12 sec
Reputation Power: 40
Send a message via MSN to pro_seo Send a message via Yahoo to pro_seo Send a message via Google Talk to pro_seo Send a message via Skype to pro_seo
Quote:
Originally Posted by andrenym00
for some reason it didn't.


Yups...and the reason is the second occurrence of the RewriteEngine On in the htaccess file.

Your previous htaccess was:

Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]


Options +FollowSymLinks
RewriteEngine on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]


The later part of the code [in italics] overwrite the previous instruction [for redirecting non-www to www] {in green} and so the redirection is only working for /index.php to /

The redirect code for non-www to www thus stands void.

Reply With Quote
  #11  
Old January 15th, 2008, 01:54 PM
andrenym00 andrenym00 is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 61 andrenym00 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 36 m 2 sec
Reputation Power: 4
Ok, thx, I have it like this now, but if I don't add http://www.example.com/ after index\.php$ non www index.php doesn't work. I guess it don't matter like you said.

Options +FollowSymlinks
RewriteEngine on

rewritecond %{http_host} ^example.com [nc]
rewriterule ^(.*)$ http://www.example.com/$1 [r=301,nc]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]

Reply With Quote
  #12  
Old January 15th, 2008, 03:38 PM
andrenym00 andrenym00 is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 61 andrenym00 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 17 h 36 m 2 sec
Reputation Power: 4
By the way, I'm a newbie at this. What does "result in loop" mean?

Reply With Quote
Reply

Viewing: SEO Chat ForumsOtherSEO Scripts > 301 redirect help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
&