Sometimes I need .htaccess mod_rewrite rule to redirect old URL to new one.
I am using the following rules:
# Add followsymlinks to server options
Options +FollowSymLinks
# It will work only if web server Apache mod_rewrite is enabled
<IfModule mod_rewrite.c>
# Turn on mod_rewrite engine
RewriteEngine On
# Should be added if virtual document root directive is used
RewriteBase /
# Redirect from /old-url
# to –> /new-url
RewriteCond %{REQUEST_URI} ^/old-url
RewriteRule ^old-url(.*)$ http://%{HTTP_HOST}/new-url$1 [NC,R=301,L]
</IfModule>
Notes:
%{REQUEST_URI} – web server Apache requested URL
%{HTTP_HOST} – your domain name: e.g. www.shkodenko.com or shkodenko.com
$1 – can be additional URL part including get parameters substituted from (.*)
this is just perfect!