|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
||||
|
||||
|
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. |
|
#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 12:26 PM. |
|
#4
|
||||
|
||||
|
Quote:
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.** |
|
#5
|
|||
|
|||
|
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. |
|
#6
|
||||
|
||||
|
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:
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 |
![]() |
| Viewing: SEO Chat Forums > Other > SEO Scripts > Simple question! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|