We need to do a rewrite for a subdirectory of a site to its own host, with the exception of one directory. We also need to be sure that the original subdirectory is dropped in the rewrite. (using hppts instead of https because otherwise the site pitches a fit at the number of links.)
Also, I am whatever rank is lower than Novice when it comes to rewrite rules and Apache in general, so please treat me accordingly.
Scenario:
We have a main site with a subdir that needs to be rewritten to its own host.
hppts://www.site.com/product
needs to be rewritten to hppts://www.product.com
However, there is one directory we want to remain intact recursively. So:
hppts://www.site.com/product/dir1/dir2/dir3
needs to continue to work without being rewritten to www.product.com
. I'm having a hell of a time figuring out how to do this. So basically I'm looking for a way to do some kind of exclusion.
Also, how do I do a rewrite so that it writes the original query, but drops the subdirectory the condition is based on. That is, when I do what I think is a proper rewrite for this:
hppts://www.site.com/product/dir5
it gets rewritten to hppts://www.product.com/product/dir5
instead of hppts://www.product.com/dir5
.
The rule the guy is trying is:
RewriteEngine on
RewriteCond %{REQUEST_URI}!^/dir1/
RewriteRule (.*) hppts://www.product.com/$1 [R=301,L]
But anything we try returns hppts://www.product.com/product/%whatever the query was%/
.
Any help is appreciated.