Search code examples
.htaccesshttp-status-code-301http-redirect

Trying to Redirect Old Page to a New Page


I've done searches and I've followed what they said but my redirect still isn't working.

.htaccess looks like this:

# 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

Redirect 301 /alaska http://www.example.com/alaska-schools?
Redirect 301 ^/delaware http://www.example.com/delaware-schools?

Any ideas what's not working here?

Thanks


Solution

  • You probably want to stick with mod_rewrite instead of mod_alias for these redirects. Having both directives (and one of them routing everything to index.php) will have them conflict. You will also want all of your redirecting before your routing. So something like this:

    RewriteRule ^alaska/?$ http://www.example.com/alaska-schools? [L,R=301]
    RewriteRule ^delaware/?$ http://www.example.com/delware-schools? [L,R=301]
    
    # 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