301 redirect code is not working with htaccess file

Discussion in 'Apache' started by meshazia, Jun 15, 2016.

  1. #1
    Hi, I want to redirect my website to a new domain.
    But nothing is happening even after uploading .htaccess file with this code at the root of my old domain.
    Please tell me if I am doing something wrong.
    Subpages have same urls as mentioned below.

    Options +FollowSymLinks
    RewriteEngine on
    Redirect 301 / MyNewDomain
    Redirect 301 /index.php MyNewDomain
    Redirect 301 /event.php MyNewDomain/ events.html
    Redirect 301 /book_online.php MyNewDomain/ online-booking.html
    Redirect 301 /contact.php MyNewDomain/ contact-us.html

    Thanks!
     
    meshazia, Jun 15, 2016 IP
  2. Roger S

    Roger S Active Member

    Messages:
    46
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    58
    #2


    Hello,

    From you update I believe you wish to completely redirect old domain to new domain, if that is the case use the following .htaccess code instead.


    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://new-domain.com/$1 [R=301,L]
    Code (ApacheConf):
    additional reference can be found here
    http://www.webconfs.com/htaccess-redirect-generator.php
     
    Roger S, Jul 10, 2016 IP