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 08-16-2007, 01:00 AM
WebProWorld Member
 
Join Date: Jun 2007
Posts: 79
thersey RepRank 2
Default 301 Redirect

Hello, I just redirected my non www URL to my www URL with the formula
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


I put it in my .htaaccess file and it redirected my URL but, my website pictures were not showing up.(some type of browser problems) Does anyone know how to fix this? When I removed the formula my pictures showed again. It also caused a problem with my log-in to my shopping Admin.
Thank you
Projector Discount Store-LCD/DLP/Home Theater
Reply With Quote
  #2 (permalink)  
Old 08-16-2007, 01:08 AM
carpediem's Avatar
WebProWorld Pro
 
Join Date: Oct 2006
Location: StudioKraft Creative Services
Posts: 110
carpediem RepRank 3carpediem RepRank 3
Default Re: 301 Redirect

Hi thersey,

Have you tried to set the HTTP_SERVER constant located in includes/configure.php to your url with the www? It appears as though you are using OSCommerce with an automated thumbnail generator and perhaps requiring it to redirect to the www domain through .htaccess is causing the problem.


~D
__________________
MODPlug Central | Free Music Software
StudioKraft | Ecommerce Web Site Development
Reply With Quote
  #3 (permalink)  
Old 08-16-2007, 01:24 AM
WebProWorld Member
 
Join Date: Jun 2007
Posts: 79
thersey RepRank 2
Default Re: 301 Redirect

Thanks, I will give it a try.
Reply With Quote
  #4 (permalink)  
Old 08-16-2007, 11:55 PM
lanlocked's Avatar
Administrator
 
Join Date: Jul 2004
Location: Ky., for now
Posts: 8
lanlocked has disabled reputation
Default Re: 301 Redirect

Quote:
Originally Posted by thersey View Post
Hello, I just redirected my non www URL to my www URL with the formula
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


I put it in my .htaaccess file and it redirected my URL but, my website pictures were not showing up.(some type of browser problems) Does anyone know how to fix this? When I removed the formula my pictures showed again. It also caused a problem with my log-in to my shopping Admin.
Thank you
Projector Discount Store-LCD/DLP/Home Theater
I am pretty sure that your rewrite rule is incorrect... we (iEntry) use something like:
<Directory /path/to/public_html/>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
</Directory>

which says (roughly):
if the url does not begin with 'www.example.com' then rewrite it to www.example.com/<whatever follows>

Your example says (roughly) if the URL begins with 'example.com' rewrite it to 'www.example.com' but you have nothing handling anything following the 'example.com' (that is what the "$" is for).

In other words, if I entered 'example.com/somethingelse' I would get redirected to 'www.example.com' - not 'www.example.com/somethingelse'; which is the desired result :/

Also, your logic is kind of wrong. Your line says, "if it begins with example.com rewrite to www.example.com" whereas you are probably better served saying "if it does not begin with 'www.example.com' rewrite to www.example.com".

The '^' refers to "begins with" and the "!" refers to does not - ie. "!^" says "does not begin with".

I am farily certain you want to change:
RewriteCond %{HTTP_HOST} ^example.com
to:
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]

This is not a browser problem -- it is acting *exactly* as you told it to
Reply With Quote
  #5 (permalink)  
Old 08-17-2007, 11:28 AM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,657
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 about the above comment. First, redirect match terms are "greedy" - if you don't specify text, text will be allowed.
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
will match example.com, example.com/index.php, etc but not Example Web Page. The ^ specifies the beginning of the string.
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Will ONLY match example.com. This is because ^ represents the beginning of the string and $ matches the end of the string. However, HTTP_HOST does not have anything after the hostname (which is the domain name) so this method would work

The problem is your rewrite rule, not the condition.

If someone goes to example.com/img/pic.jpg, you are redirecting them to www.example.com//img/pic.jpg (note the extra slash). The rewrite rule should be rewritten as: RewriteRule /(.*) http://www.example.com/$1 [R=301,L]
__________________
The best way to learn anything, is to question everything.
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? watto Search Engine Optimization Forum 8 08-02-2006 10:41 AM
301 Redirect tonya1 Search Engine Optimization Forum 16 08-31-2005 04:12 PM
Redirect 301 jeannemalherbe Search Engine Optimization Forum 4 11-16-2004 04:40 AM
301 redirect - which is best groenie Search Engine Optimization Forum 8 10-07-2004 06:46 AM
301 redirect help Blayne Google Discussion Forum 11 05-04-2004 12:13 AM


All times are GMT -4. The time now is 02:56 AM.



Search Engine Optimization by vBSEO 3.3.0