301 redirect using .htaccess (one webpage to another)

Hi,

I am trying to redirect one web page to another using a 301 redirect. The code I am using is:

RewriteEngine On
redirect 301 /link1.htm http://www.sitename.com/link2.htm
  redirect 301 /link3.htm http://www.sitename.com/link4.htm

The 301 redirect is not working at the moment.

What is wrong with this code? Can someone help me, please?

Kind regards,

Matt.

There’s actually nothing wrong with that code. I copy-pasted it, and it works as expected. The real problem must be elsewhere.

Matt,

Since this is NOT mod_rewrite (the Redirect family of directives belong to mod_alias), I’d first remove your RewriteEngine on statement. Then, if this is in the DocumentRoot’s .htaccess, I’d remove the leading / from your Redirect statements. THEN it will work properly.

Regards,

DK

It is still not working.

My complete .htaccess file looks like this:

Notice I am redirecting based upon capitalisation.

  redirect 301 Gatso.htm http://www.speedcamerasuk.com/gatso.htm
  redirect 301 Truvelo.htm http://www.speedcamerasuk.com/truvelo.htm

<IfModule mod_expires.c>
  # Enable expirations
    ExpiresActive On
    # Default directive
    ExpiresDefault "access plus 1 month"
    # My favicon
    ExpiresByType image/x-icon "access plus 1 yearÓ
    # Images
    ExpiresByType images/gif "access plus 1 month"
    ExpiresByType images/png "access plus 1 month"
    ExpiresByType images/jpg "access plus 1 month"
    ExpiresByType images/jpeg "access plus 1 month"
    # CSS
    ExpiresByType text/css "access 1 monthÓ
    # Javascript
    ExpiresByType application/javascript "access plus 1 year"
    # compress text, HTML, JavaScript, CSS, and XML
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    # remove browser bugs
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\\.0[678] no-gzip
    BrowserMatch \\bMSIE !no-gzip !gzip-only-text/html
    Header append Vary User-Agent
  </p>
</IfModule>

Looks like you have a stray </p> in there. That shouldn’t be there, and it’s causing a syntax error.

Then you’ll also have to add leading slashes on the old URL you’re redirecting from. (The Redirect directive matches against the request path and always begins with a slash.)

  redirect 301 [SIZE=4][COLOR="#FF0000"]/[/COLOR][/SIZE]Gatso.htm http://www.speedcamerasuk.com/gatso.htm
  redirect 301 [SIZE=4][COLOR="#FF0000"]/[/COLOR][/SIZE]Truvelo.htm http://www.speedcamerasuk.com/truvelo.htm