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
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to redirect urls with a keyword to the site root

    Hi,

    I have re-built all my web site

    The old site was built with frames.
    Therefore numbers of urls are indexed by search engines in the following shape : http://www.mysite.com/index.html?target=page_xxx.html
    So every of this url group has the keyword "target" inside

    There is no frame in the new site
    I am searching a way to write a redirection (in the htaccess file) from all the above urls to the site root : http://www.mysite.com

    I thank you in advance for any help in this matter.

    Best Regards,

    Patrick

  • #2
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    put into your .htaccess something like this:


    PHP Code:
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond 
    %{REQUEST_FILENAME} !-d
    RewriteRule 
    ^(.+).html$ /index.html?target=$[L,R=301
    and try to access mysite.com/page_xxx.html

  • #3
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi,

    Thank you poyzn for your reply.

    I tried to add the 3 given lines to my htaccess file :
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)\.html$ /index.html?target=$1 [L,R=301]


    Then, I tried to open the here below url :
    http://www.mysite.com/index.html?target=page_xxx.html


    a- I got an error message in Google Chrome (in private navigation) :
    "cette page présente une boucle de redirection" (this page has a redirect loop)
    or
    b- I got an error message in Firefox :
    "La page n'est pas redirigée correctement" (The page is not properly redirected)

    The displayed url in the browser bar was :
    http://www.mysite.com/index.html?target=index

    As a piece of information, I add that my new site root is :
    http://www.mysite.com/index.php (or http://www.mysite.com)
    and not
    http://www.mysite.com/index.html

    I thank you in advance if you can try to help me once again.

    Kind Regards,

    Patrick

  • #4
    Regular Coder poyzn's Avatar
    Join Date
    Nov 2010
    Posts
    266
    Thanks
    2
    Thanked 61 Times in 61 Posts
    I assume that you don't have index.html
    What language do you use on your server?

    If it is php I suggest you to use index.php instead of index.html and mod_rewrite config should be:
    PHP Code:
    RewriteCond %{REQUEST_FILENAME} !-// If there is no file with such name
    RewriteCond %{REQUEST_FILENAME} !-// or directory
    RewriteRule ^(.+).html$ /index.php?target=$[L,R=301// do rewrite with 301 redirect to remove old urls from search engines indexes 
    Last edited by poyzn; 11-13-2012 at 06:45 PM.


  •  

    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
    •