htaccess how to redirect subdirectory to external URL
.htaccess, apache, mod-rewrite, redirect, regex
Solution
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]
Problem
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.