Htaccess how to redirect a subdirectory to an external URL

I tried:

//301 Redirect Old File
Redirect 301 www.mydomain.com/subdirectory http://newurl.com

but it turns me on in newurl.com/subdirectory, which doesn't exist.

+5
source share
1 answer

Include mod_rewrite and .htaccess, then add this code to your .htaccess in 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]
+11
source

All Articles