iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Search Engine Optimization Forum SEO is much easier with help from peers and experts! The WebProWorld SEO forum is for the discussion and exploration of various search engine optimization topics. Any non (engine) specific SEO or SEM topics should go here.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-01-2007, 10:13 PM
WebProWorld New Member
 
Join Date: Jul 2007
Posts: 9
magosla2001 RepRank 0
Default 301 Redirect

I tried a 301 redirection to my blog with the below script;

Code:
 
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(.*)\.magnuslator\.com$ [NC]
RewriteRule ^(.*)$ http://www.magnuslator.com/weblog/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(.*)\.www\.magnuslator\.com$ [NC]
RewriteRule ^(.*)$ http://www.magnuslator.com/weblog/$1 [R=301,L]
The problem i experience is it redirects to Magnus Lator instead of Magnus Lator.
Reply With Quote
  #2 (permalink)  
Old 11-02-2007, 11:33 AM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,629
wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9
Default Re: 301 Redirect

What exactly are you trying to do? Redirect everything that has a subdomain other than www to the www version? Or only redirect the requests with no subdomain? Because these directives seem to look for a subsubdomain, which you probably do not have.
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #3 (permalink)  
Old 11-03-2007, 03:57 PM
WebProWorld New Member
 
Join Date: Jul 2007
Posts: 9
magosla2001 RepRank 0
Default Re: 301 Redirect

I am redirecting only Magnus Lator & magnuslator.com to Magnus Lator. But I have been able to retify the problem. It was from wordpress General Options. The url was set as Magnus Lator instead of Magnus Lator
Reply With Quote
  #4 (permalink)  
Old 11-05-2007, 04:07 PM
incrediblehelp's Avatar
WebProWorld 1,000+ Club
WebProWorld MVP
 
Join Date: Jan 2004
Location: Live in Cincy Now
Posts: 7,573
incrediblehelp RepRank 4incrediblehelp RepRank 4incrediblehelp RepRank 4incrediblehelp RepRank 4incrediblehelp RepRank 4
Default Re: 301 Redirect

Working here for me
Reply With Quote
  #5 (permalink)  
Old 12-21-2007, 04:19 AM
WebProWorld New Member
 
Join Date: Jul 2007
Posts: 9
magosla2001 RepRank 0
Default Re: 301 Redirect

I am having problem with this .htacess script;

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

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


The problem is it tries opening http://www.mysite.com/f/f/f/f/f/fffffffff/f/f/f/f/f/f/
in this case the /f is being repeated.
Reply With Quote
  #6 (permalink)  
Old 12-21-2007, 10:55 AM
WebProWorld Pro
 
Join Date: Dec 2007
Location: Brussels, Belgium
Posts: 163
Jean-Luc RepRank 2
Default Re: 301 Redirect

I would try this:
Code:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$
RewriteRule ^(.*)$ http://www.mysite.com/f/$1 [L,R=301]
RewriteRule ^f\/ - [L]
RewriteRule ^(.*)$ http://www.mysite.com/f/$1 [L,R=301]
This .htaccess should redirect any hit on the www site to the /f directory and any other subdomain to the /f directory of the www site.

Jean-Luc
__________________
Checking redirects made easy | | Professional AWStats Services
Reply With Quote
  #7 (permalink)  
Old 12-21-2007, 11:07 AM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,629
wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9
Default Re: 301 Redirect

Two things. First, you are combining two redirects that need to be seperate, second, do you actually have sub-subdomains?

RewriteEngine On
# First, force everything to the www. subdomain
RewriteCond %{HTTP_HOST !^(.*)\.mysite\.com$
RewriteRule ^(.*)$ http://www.mysite.com/ [R=301, L]
# Then rewrite all requests so that they go to the /f/ folder.
RewriteCond %{REQUEST_URI} !^/f/
RewriteRule ^/(.*)$ http://www.mysite.com/f/$1 [R=301, L]
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #8 (permalink)  
Old 12-21-2007, 03:13 PM
WebProWorld New Member
 
Join Date: Jul 2007
Posts: 9
magosla2001 RepRank 0
Default Re: 301 Redirect

For now I want all request to be redirected to the F directory with www site. The same 301 redirect script was used on one of my sites and it worked perfect. But in this case it opens /f/f/f/f/f/f/
Reply With Quote
  #9 (permalink)  
Old 12-21-2007, 03:35 PM
WebProWorld Pro
 
Join Date: Dec 2007
Location: Brussels, Belgium
Posts: 163
Jean-Luc RepRank 2
Default Re: 301 Redirect

That's because of the recursion here:
Code:
RewriteCond %{HTTP_HOST} !^(.*)\.www\.mysite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com/f/$1 [R=301,L]
Did you try my suggestion ?

Jean-Luc
__________________
Checking redirects made easy | | Professional AWStats Services
Reply With Quote
  #10 (permalink)  
Old 12-21-2007, 04:00 PM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,629
wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9
Default Re: 301 Redirect

I think with older versions of Apache, the RewriteEngine on directive acted as kind of a reset of the rules. The thing to remember is that {HTTP_HOST} never contains anything but the domain/subdomain. So for your second rule, where you are trying to test the requested path, that will never be contained in the host line. A request for a page on your site looks like the following:

GET /somefolder/somepage.html
Host: www.somedomain.com

To test what folder the user is requesting, you need to use the value on the GET (or if form data is being submitted, POST) line, which is in the {REQUEST_URI} variable for mod_rewrite. You also are not testing if the user is already in the /f/ folder, which is why the user gets stuck in an endless loop.
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #11 (permalink)  
Old 12-21-2007, 04:17 PM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,629
wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9
Default Re: 301 Redirect

Jean-Luc, just to make sure I am reading your rules correctly:

RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ #you are testing for the proper domain
RewriteRule ^(.*)$ http://www.mysite.com/f/$1 [L,R=301] #You are sending the user to the correct domain
RewriteRule ^f\/ - [L] #If the user is already in the f folder, you stop redirecting
RewriteRule ^(.*)$ http://www.mysite.com/f/$1 [L,R=301] #Otherwise you send the user to the f directory

If that is correct, I see a potential problem. If somehow the www. gets dropped from an otherwise valid link, the user will get an extra /f/ directory. In other words, a request to domain.com/f/page.html would redirect to www.domain.com/f/f/page.html. I would remove the /f from the second line, separate detection of the subdomain from detection of the folder.
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #12 (permalink)  
Old 12-21-2007, 05:44 PM
WebProWorld Pro
 
Join Date: Dec 2007
Location: Brussels, Belgium
Posts: 163
Jean-Luc RepRank 2
Default Re: 301 Redirect

Wige,

I agree. Your remark is valid, but I believe that magosla2001 will never get hits on the f directory in other subdomains (I got the impression that the f directory was recently created), but I can be wrong.

Jean-Luc
__________________
Checking redirects made easy | | Professional AWStats Services
Reply With Quote
  #13 (permalink)  
Old 12-21-2007, 06:11 PM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,629
wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9
Default Re: 301 Redirect

Jean-Luc,

I definitely agree, it is unlikely, but just suggest it because it will provide a small amount of future proofing. You never know when a spider might get a URL wrong for some reason, (Slurp, for example) or a webmaster in the future leaves a www off an inbound link.
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #14 (permalink)  
Old 12-21-2007, 06:57 PM
WebProWorld Pro
 
Join Date: Dec 2007
Location: Brussels, Belgium
Posts: 163
Jean-Luc RepRank 2
Default Re: 301 Redirect

Absolutely right. You cannot be too careful.

Jean-Luc
__________________
Checking redirects made easy | | Professional AWStats Services
Reply With Quote
Reply

  WebProWorld > Search Engines > Search Engine Optimization Forum

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
301 Redirect wmrobwl Search Engine Optimization Forum 3 09-18-2006 05:08 PM
Geo Redirect jacobwissler Google Discussion Forum 0 08-22-2006 03:33 PM
301 redirect? watto Search Engine Optimization Forum 8 08-02-2006 10:41 AM
more redirect help plz!!! roam_dx Search Engine Optimization Forum 4 07-11-2005 01:20 AM
301 redirect and PR mantawebsolutions Search Engine Optimization Forum 0 10-07-2004 03:46 AM


All times are GMT -4. The time now is 12:43 AM.



Search Engine Optimization by vBSEO 3.3.0