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, 08: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: 2
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 08:37 AM.

Reply With Quote
  #2  
Old December 15th, 2007, 08:40 AM
dzine's Avatar
dzine dzine is offline
Vergruizer: Vot tebe khuy
SEO Chat Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2005
Location: in a life preserver @ seorefugee
Posts: 1,963 dzine User rank is Sergeant Major (2000 - 5000 Reputation Level)dzine User rank is Sergeant Major (2000 - 5000 Reputation Level)dzine User rank is Sergeant Major (2000 - 5000 Reputation Level)dzine User rank is Sergeant Major (2000 - 5000 Reputation Level)dzine User rank is Sergeant Major (2000 - 5000 Reputation Level)dzine User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Month 6 Days 21 h 30 m 25 sec
Reputation Power: 30
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, 12:24 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: 2
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 12:26 PM.

Reply With Quote
  #4  
Old December 15th, 2007, 01:55 PM
pro_seo's Avatar
pro_seo pro_seo is online now
Moderator
SEO Chat Frequenter (2500 - 2999 posts)
 
Join Date: Apr 2006
Location: I N D I A
Posts: 2,950 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 4 Weeks 1 Day 18 h 52 m 54 sec
Reputation Power: 44
Send a message via AIM to pro_seo 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 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, 02: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: 2
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 02:41 PM.

Reply With Quote
  #6  
Old December 16th, 2007, 04:41 AM
pro_seo's Avatar
pro_seo pro_seo is online now
Moderator
SEO Chat Frequenter (2500 - 2999 posts)
 
Join Date: Apr 2006
Location: I N D I A
Posts: 2,950 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 4 Weeks 1 Day 18 h 52 m 54 sec
Reputation Power: 44
Send a message via AIM to pro_seo 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
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 04: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!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

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





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT