apache - 301 redirect entire domain to corresponding URL on new domain - EXCEPT for one directory -
as title says, migrating website olddomain.com newdomain.com. have htaccess 301 redirect in place in web root of olddomain.com follows redirects request olddomain.com/any/url same corresponding url on newdomain.com:
rewriteengine on rewritebase / rewritecond %{http_host} !newdomain.com$ [nc] rewriterule ^(.*)$ http://newdomain.com/$1 [l,r=301] my question is, how can modify rewrite rule exclude 1 specific directory? olddomain.com/downloads continue serve file mirror, need exclude olddomain.com/downloads (and subdirectories such /releases, etc) original site-wide 301 redirect such request url on olddomain.com redirected corresponding url on newdomain.com exception of request file or directory lives inside olddomain.com/download.
edit mentioned in comments below, need exclude olddomain.com/getlatest.php redirect, since generates download link relies on parsing server directory structure.
you can use negative condition in rewriterule:
rewriteengine on rewritecond %{http_host} !newdomain\.com$ [nc] rewriterule !^(downloads(/.*)?|getlatest\.php)$ http://newdomain.com%{request_uri} [l,r=301,ne,nc]
Comments
Post a Comment