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 December 15th, 2007, 07:25 AM
MrMiguel MrMiguel is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 63 MrMiguel User rank is Private First Class (20 - 50 Reputation Level)MrMiguel User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 10 h 40 m 3 sec
Reputation Power: 3
Simple question!

The only thing I still want to do is redirecting (or rewriting?) http://www.mywebsite.com/index.html to http://www.mywebsite.com/

How do I do this?

Code:
Redirect 301 /index.html http://www.mywebsite.com/

didn't work...

My full .htaccess file now looks like this:

Code:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.mywebsite.com$ [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R=301]
RewriteRule ^(.*)\.htm$ $1.html [R=301,L]

Thanks so much for your help!!

ps. Could someone check that the above .htaccess-file is 'valid', in the sense that there's no chance of never-ending loops or something like that? The RewriteCond for instance, does that one now also hold for the second RewriteRule? Yes, I'm am .htaccess-noob....

Last edited by MrMiguel : December 15th, 2007 at 07:37 AM.

Reply With Quote
  #2  
Old December 15th, 2007, 07:40 AM
dzine's Avatar
dzine dzine is offline
Vergruizer: Vot tebe khuy
SEO Chat Frequenter (2500 - 2999 posts)
 
Join Date: Oct 2005
Location: in a life preserver @ seorefugee
Posts: 2,508 dzine User rank is First Lieutenant (10000 - 20000 Reputation Level)dzine User rank is First Lieutenant (10000 - 20000 Reputation Level)dzine User rank is First Lieutenant (10000 - 20000 Reputation Level)dzine User rank is First Lieutenant (10000 - 20000 Reputation Level)dzine User rank is First Lieutenant (10000 - 20000 Reputation Level)dzine User rank is First Lieutenant (10000 - 20000 Reputation Level)dzine User rank is First Lieutenant (10000 - 20000 Reputation Level)dzine User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 21 h 34 m 24 sec
Reputation Power: 145
What did you mean "didn't work"? Endless loop?
I haven't tested this exactly, but you may wanna change the line:

RewriteCond %{HTTP_HOST} !^www.mywebsite.com$ [NC]

...to:

RewriteCond %{HTTP_HOST} ^mywebsite.com$ [NC]

...and add the new redirect bit.

Reply With Quote
  #3  
Old December 15th, 2007, 11:24 AM
MrMiguel MrMiguel is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 63 MrMiguel User rank is Private First Class (20 - 50 Reputation Level)MrMiguel User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 10 h 40 m 3 sec
Reputation Power: 3
Yeah I tested it again and:

Code:
Redirect 301 /index.html http://www.mywebsite.com/

Indeed gives an endless loop (the page doesn't get loaded but my browser instead keeps refreshing like crazy)

Is there some way to make it work anyway?

(Concerning your other remark; thanks but RewriteCond %{HTTP_HOST} !^www.mywebsite.com$ [NC] actually does work well too.)

Last edited by MrMiguel : December 15th, 2007 at 11:26 AM.

Reply With Quote
  #4  
Old December 15th, 2007, 12:55 PM
pro_seo's Avatar
pro_seo pro_seo is offline
Moderator
SEO Chat Expert (3500 - 3999 posts)
 
Join Date: Apr 2006
Location: I N D I A
Posts: 3,512 pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 6 h 41 m 16 sec
Reputation Power: 175
Send a message via Skype to pro_seo
Quote:
Originally Posted by MrMiguel
Yeah I tested it again and:

Code:
Redirect 301 /index.html http://www.mywebsite.com/

Indeed gives an endless loop (the page doesn't get loaded but my browser instead keeps refreshing like crazy)

Is there some way to make it work anyway?

(Concerning your other remark; thanks but RewriteCond %{HTTP_HOST} !^www.mywebsite.com$ [NC] actually does work well too.)


try this

Code:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(.*)index\.html$ /$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
  #5  
Old December 15th, 2007, 01:34 PM
MrMiguel MrMiguel is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 63 MrMiguel User rank is Private First Class (20 - 50 Reputation Level)MrMiguel User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 10 h 40 m 3 sec
Reputation Power: 3
Thanks man, that one worked!!

By the way; does it matter where in the 'old' .htaccess-code I place the by you suggested code:

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

I mean, for how many lines does such a RewriteCond for instance hold?

Is the below fully correct? If everything works for me, can I then be sure that it works for everyone else?

Code:
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.mywebsite.com$ [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R=301,L]
RewriteRule ^(.*)\.htm$ $1.html [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
RewriteRule ^(.*)index\.html$ /$1 [R=301,L]


Is it a problem I've got three times the expression [R=301,L]? Should RewriteRule ^(.*)\.htm$ $1.html [R=301,L] maybe be placed below RewriteRule ^(.*)index\.html$ /$1 [R=301,L]?

Last edited by MrMiguel : December 15th, 2007 at 01:41 PM.

Reply With Quote
  #6  
Old December 16th, 2007, 03:41 AM
pro_seo's Avatar
pro_seo pro_seo is offline
Moderator
SEO Chat Expert (3500 - 3999 posts)
 
Join Date: Apr 2006
Location: I N D I A
Posts: 3,512 pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level)pro_seo User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 6 h 41 m 16 sec
Reputation Power: 175
Send a message via Skype to pro_seo
Sorry mate, but I am not a coding expert..so I don't think that I know all that you are asking.

However, my guess is that you want to solve 2 canonical issues with these redirects.

* from http://domain.com/ to http://www.domain.com/

* from http://www.domain.com/index.html to http://www.domain.com/

If these are the 2 that you want to solve then this is how your HTACCESS should look like:

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

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


This should help!

EDIT: The order of placing these codes doesn't really matter. You can place the 2nd code first and it will work as well.

I usually leave a line break in between the codes placed. Works fine for me.

Quote:
Is it a problem I've got three times the expression [R=301,L]? Should RewriteRule ^(.*)\.htm$ $1.html [R=301,L] maybe be placed below RewriteRule ^(.*)index\.html$ /$1 [R=301,L]?


IMO it isn't a problem that you have [R=301,L] three times within the file.

And yes, RewriteRule ^(.*)\.htm$ $1.html [R=301,L] can be placed at the last as well. Just leave a line break in between..just to be safe and clear to understand where each code starts and ends.

Last edited by pro_seo : December 16th, 2007 at 03:52 AM. Reason: added further information

Reply With Quote
Reply

Viewing: SEO Chat ForumsOtherSEO Scripts > Simple question!


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




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

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




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek