...

View Full Version : .htaccess 301 redirection with exceptions



AaronBE
07-17-2011, 10:28 PM
Hello.

I want to redirect all the incorrect calls of a web to the main page. Correct calls must be works as normally.

I have this sctucture:

www.domain.com
-en/
--index.php (main page)
--...
-images/
--logo.gif
--...
-sitemap.html
-robots.txt

A call to www.domain.com/sitemap.html must show the sitemap.html
A call to www.domain.com/en/something must show something
Same with images/ an robots.txt
Calls to www.domain.com/mistaken_uri must be redirected 301 to www.domain.com/en/index.php

I've tried with:

RewriteCond %{REQUEST_URI} !^(sitemap\.html|robots\.txt|en|images)
RewriteRule ^(.*)$ http://www.domain.com/ca/index.php [R=301,L]

But it doesn't work.

Any idea?

Jinxy
07-18-2011, 08:48 PM
Hello.

I want to redirect all the incorrect calls of a web to the main page. Correct calls must be works as normally.


Why not use this?



ErrorDocument 404 http://www.domain.com/ca/index.php

AaronBE
07-19-2011, 05:14 PM
because some weeks ago i've changed some files and folders names and about 50 of them are indexed on google. The result in Google shows a 404 error, i'd like redirect them to the main page.

Thanks for you answer.

Jinxy
07-19-2011, 06:19 PM
because some weeks ago i've changed some files and folders names and about 50 of them are indexed on google. The result in Google shows a 404 error, i'd like redirect them to the main page.

Thanks for you answer.

That will redirect ALL 404 errors to whatever page you assign to it. If http://www.domain.com/ca/index.php is not your main page then change it to whatever url is your main page.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum