|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
Use this one:
Quote:
__________________
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.** |
|
#3
|
|||
|
|||
|
Ok, it worked for http://www.blahblah.com/index.php, but not for http://blahblah.com/index.php . Does it matter?
|
|
#4
|
|||
|
|||
|
for example if i use http://blahblah.com/index.php it redirects to http://www.blahblah.com/http://www.blahblah.com/
|
|
#5
|
||||
|
||||
|
Quote:
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/ |
|
#6
|
|||
|
|||
|
Quote:
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 |
|
#7
|
|||
|
|||
|
Quote:
for some reason it didn't. |
|
#8
|
||||
|
||||
|
Quote:
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 |
|
#9
|
||||
|
||||
|
Quote:
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."** **" |
|
#10
|
||||
|
||||
|
Quote:
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. |
|
#11
|
|||
|
|||
|
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] |
|
#12
|
|||
|
|||
|
By the way, I'm a newbie at this. What does "result in loop" mean?
|
![]() |
| Viewing: SEO Chat Forums > Other > SEO Scripts > 301 redirect help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|