Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-17-2011, 09:28 PM   PM User | #1
AaronBE
New to the CF scene

 
Join Date: Jul 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
AaronBE is an unknown quantity at this point
.htaccess 301 redirection with exceptions

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?
AaronBE is offline   Reply With Quote
Old 07-18-2011, 07:48 PM   PM User | #2
Jinxy
New Coder

 
Join Date: Feb 2007
Posts: 86
Thanks: 0
Thanked 2 Times in 2 Posts
Jinxy has a little shameless behaviour in the past
Quote:
Originally Posted by AaronBE View Post
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?

Code:
ErrorDocument 404 http://www.domain.com/ca/index.php
Jinxy is offline   Reply With Quote
Old 07-19-2011, 04:14 PM   PM User | #3
AaronBE
New to the CF scene

 
Join Date: Jul 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
AaronBE is an unknown quantity at this point
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.
AaronBE is offline   Reply With Quote
Old 07-19-2011, 05:19 PM   PM User | #4
Jinxy
New Coder

 
Join Date: Feb 2007
Posts: 86
Thanks: 0
Thanked 2 Times in 2 Posts
Jinxy has a little shameless behaviour in the past
Quote:
Originally Posted by AaronBE View Post
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.
Jinxy is offline   Reply With Quote
Reply

Bookmarks

Tags
apache, htaccess, mod_rewrite, redirect

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:33 AM.


Advertisement
Log in to turn off these ads.