Forum Moderators: phranque
RewriteRule ^example.org/(.*) https://example.org/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/example.org/
RewriteRule ^(.*) https://example.org/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^ourhostingdomain.com/example1/
RewriteRule ^(.*) https://example1.org/$1 [R=301,L] https://www.ourhostingdomain.com/example1/ is the site I don't want to have people see or be indexed; https://www.example1.org is the site I do want seen/indexed.
I wonder if it would work, in each site, to putThe hostname isn't part of the REQUEST_URI; only the path. You have to leave off the “ourhostingdomain.com” element.
In my case, I wonder if it would work, in each site, to put:
RewriteCond %{REQUEST_URI} ^ourhostingdomain.com/example1/
RewriteRule ^(.*) https://example1.org/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^(www\.example\.org)?$ [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://www.example.org/$1 [R=301,L] www.ourhostingdomain.com/example1 www.example1.com www.ourhostingdomain.com/example1 www.example1.com
but the same .htaccess file will be in the root folder of both websites (because both "websites" point to the same physical files).This doesn't make sense. Sure, requests for example.org and example.com/example.org will both pass through the htaccess for example.com--but it doesn't matter, thanks to mod_rewrite's wonky inheritance rules. Only the rules in example.org's individual htaccess will apply.
You did say, did you not, that each domain--including the addons--has its own htaccess?
www.ourhostingdomain.com/example1
www.example1.com RewriteCond %{HTTP_HOST} !^(www.ourhostingdomain.com/example1)?$ [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://www.example1.com/$1 [R=301,L]
In per-directory context (Directory and .htaccess), the Pattern is matched against only a partial path, for example a request of "/app1/index.html" may result in comparison against "app1/index.html" or "index.html" depending on where the RewriteRule is defined.
The directory path where the rule is defined is stripped from the currently mapped filesystem path before comparison (up to and including a trailing slash). The net result of this per-directory prefix stripping is that rules in this context only match against the portion of the currently mapped filesystem path "below" where the rule is defined.
Directives such as DocumentRoot and Alias, or even the result of previous RewriteRule substitutions, determine the currently mapped filesystem path.
I wonder if this would work per suggestion above? (though not clear what the "or" and following line is for).
RewriteCond %{HTTP_HOST} !^(www.ourhostingdomain.com/example1)?$ [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://www.example1.com/$1 [R=301,L]
www.ourhostingdomain.com/example1/.htaccess
www.example1.com/.htaccess You keep saying yes, but it sounds as if you really mean no: There is only one htaccess file, located in the "primary" folder.
www.ourhostingdomain.com/example1/.htaccess
www.example1.com/.htaccess I believe what I need is a command in "www.ourhostingdomain.com/example1/.htaccess" that will point anyone getting the file via "www.ourhostingdomain.com/example1/" to be pointed instead to "www.example1.com" with a 301 redirect - but will not cause a loop for people accessing it via "www.example1.com".
Also, because they are the same file, I'm not sure a mod_rewrite would help. But I may just not be brainy enough to figure it out.
KallenWeb, have you tried the mod_rewrite directives i suggested above?
These are the same file:They can't be. htaccess is dependent on physical directory, and you are describing two different physical directories. One is the primary domain, the one you call
[edited by: lucy24 at 3:14 am (utc) on Feb 6, 2019]
RewriteCond %{HTTP_HOST} !^example\.addon$ [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://example.addon/$1 [R=301,L]
(This is the form for an https site. If it is http, remove the OR flag and the second Condition.) RewriteCond %{HTTP_HOST} !(example1\.addon|example2\.addon|example3\.addon)
RewriteCond %{HTTP_HOST} !^example\.primary$ [NC,OR]
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://example.primary/$1 [R=301,L]
(There are other ways to achieve the same result, but this is probably the easiest.) RewriteCond %{REQUEST_URI} !robots\.txt
but that's a matter for a different thread. [edited by: phranque at 10:45 pm (utc) on Feb 6, 2019]
[edit reason] edit typos [/edit]