htaccess how to redirect subdirectory to external URL
11,222
Enable mod_rewrite and .htaccess then add this code in your .htaccess under DOCUMENT_ROOT:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
RewriteRule ^subdirectory/?$ http://newurl.com [L,R=301,NC]
Author by
Miles Pfefferle
I am a graphic designer, photographer, and web designer.
Updated on June 12, 2022Comments
-
Miles Pfefferle almost 2 years
I tried:
//301 Redirect Old File Redirect 301 www.mydomain.com/subdirectory http://newurl.com
but that lands me at newurl.com/subdirectory, which doesn't exist.