• Alex Connor

    (@yodelaydotco)


    Following a client website redesign and restructure, I need to set up some redirects from old pages to new/updated pages. WordPress has just been introduced to the company to replace the old hardcoded HTML/CSS site, and I’m now looking into redirecting to new page structures so that Google results still take users to the correct place following the change.

    I’m trying to achieve this using .htaccess, but it’s simply not working. Here’s what I have:

    RewriteEngine On
    Redirect 301 /contact.php/ /get-in-touch/
    
    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    Not sure why this isn’t working – going to the outdated URL simply displays the default 404 page template and doesn’t redirect at all. I’ve tried a number of different things, including:

    Redirect 301 /contact.php/ https://www.domain.com/get-in-touch/

    and

    RewriteRule ^contact/(.php)$ /get-in-touch/$1 [R=301,NC,L]

    Nothing seems to work! Any suggestions?

    Many thanks in advance.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Try dropping the trailing slashes
    Redirect 301 /contact.php /get-in-touch

    “Redirect” does not accept regexp arguments. If you want to use regexp, use RedirectMatch

Viewing 1 replies (of 1 total)
  • The topic ‘301 redirects using .htaccess not working’ is closed to new replies.