Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    .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?

  • #2
    New Coder
    Join Date
    Feb 2007
    Posts
    86
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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

  • #3
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    New Coder
    Join Date
    Feb 2007
    Posts
    86
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •