michi
michi

Reputation: 6625

Redirect old links with .htaccess

On my Joomla 2.5-site, I renamed...

http://www.my-site.com/old-link.html

for SEO-performance to

http://www.my-site.com/new-link.html

The old URL is listed on Google, though. How can I 301 redirect / rewrite clicks to the new URL?

This is my current .htaccess including SEF-links and rewriting non-www to www:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* index.php [F,L]

RewriteCond %{HTTP_HOST} ^my-site.com$ [NC]
RewriteRule ^(.*)$ http://www.my-site.com/$1 [R=301,L]

RewriteBase /

## Begin - Joomla! core SEF Section.
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]

# take care of sitemap.xml
RewriteCond %{REQUEST_URI} ^/sitemap.xml
RewriteRule .* /index.php?option=com_xmap&view=xml&tmpl=component&id=1&format=html [L]

Upvotes: 1

Views: 559

Answers (1)

Jon Lin
Jon Lin

Reputation: 143876

You need to add this at the top (just below the RewriteEngine On line):

RewriteRule ^old-link\.html$ /new-link.html [L,R=301]

Upvotes: 2

Related Questions