I have been using .htaccess to redirect URL’s on an old website to a sub domain containing the old site files. For example, my .htaccess file is full of rules like the following:
RewriteRule ^some-file.html$ http://subdomain.domain.com/some-file.html [NC,R=301,L]
However, there is one file in the subdirectory that I would like to point to a different URL. How can I reverse this for one file, and have http://subdomain.domain.com 301 redirect to http://www.domain.com/some/directory/?
Edit: This is what I currently have in my .htaccess
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^old\.domain\.com$ [NC]
RewriteRule ^(somefile.html)/?$ http://www.domain.com/some/directory/ [L,R=302,NC]
RewriteCond %{HTTP_HOST} ^old\.domain\.com$ [NC]
RewriteRule ^(some-file.html)/?$ http://www.domain.com/some/directory/ [L,R=302,NC]
Put this code in your
.htaccessunderDOCUMENT_ROOTdirectory ofsubdomain.domain.com:Once you have verified that rule is working fine just change
R=302toR=301.This will redirect
some-file.htmlor`somefile.htmlto redirect towww.domain.com/some/directory/