Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

htaccess how to redirect subdirectory to external URL

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.

like image 930
Miles Pfefferle Avatar asked Apr 05 '12 18:04

Miles Pfefferle


1 Answers

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]
like image 192
anubhava Avatar answered Sep 21 '22 22:09

anubhava