Redirect a URL to another URL

Discussion in 'Apache' started by schwarzes, Aug 2, 2010.

  1. #1
    Hello,

    I want to redirect a URL to another URL.

    I am inserting this code into the .htaccess file.

    Redirect / "http://newdomain.com/"
    Code (markup):
    The issue is that the old URL is in a particular folder, and the new domain on the root.

    For example, I am trying to redirect http://www.olddomain.com/shop/ to http://www.newdomain.com/

    Using that code redirects me to http://www.newdomain.com/shop/

    How can I redirect it to the root URL ?

    Thanks in advance.
     
    schwarzes, Aug 2, 2010 IP
  2. gapz101

    gapz101 Well-Known Member

    Messages:
    524
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    150
    #2
    RewriteRule ^shop/(.*)?$ /$1
     
    gapz101, Aug 2, 2010 IP
  3. schwarzes

    schwarzes Peon

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I used it, but nothing happened.

    I am not rewriting the URL, I am redirecting it to another URL.
     
    schwarzes, Aug 2, 2010 IP
  4. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #4
    In .htaccess try:
    RewriteEngine On
    RewriteRule ^shop/(.*)?$ http://newdomain.com/$1 [R=301]
    
    Code (markup):
     
    tolra, Aug 2, 2010 IP