Forum Moderators: phranque
Options -Indexes
AuthName example.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteCond %{REQUEST_URI} !^/s1/j1/
RewriteRule (.*) /s1/j1/$1 [L] Is this OK or am I missing something.
First things first: What else is on your site? Are the top two layers of directories empty, so a request for www.example.com by itself leads nowhere? Otherwise, how can the site tell whether a request for
example.com/pagename.html
is really a request for
example.com/s1/j1/pagename.html
or for
example.com/pagename.html
?
Domain names are case-insensitive, because this part happens before the request ever reaches your site. You can force a particular casing if you want. I don't know whether search engines care about casing; they definitely care whether www. is present or absent, so always redirect to one form.
RewriteCond %{HTTP_HOST} ^freedomandpower\.ws$ [OR]
RewriteCond %{HTTP_HOST} ^www\.freedomandpower\.ws$ Your rule as written is not any kind of redirect, whether temporary or permanent. It is a rewrite. This happens to be what you want--
but you MUST precede it with the other part of the rule, the redirect from /s1/j1/ to the form without /s1/j1/. Don't allow users to use both forms, unless you truly don't give a hoot about Duplicate Content.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/s1/j1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /s1/j1/$1 [L] When you get to the rewrite, the hostname is irrelevant unless you have subdomains to exclude. By the time you get there, all other aspects of the hostname have already been standardized.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC]
RewriteCond %{REQUEST_URI} !^/s1/j1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /s1/j1/$1 [L]
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC]
RewriteRule ^(/)?$ /s1/j1/index.php [L] Options -Indexes
AuthName example.com
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteCond %{REQUEST_URI} !^/s1/j1/
RewriteRule (.*) /s1/j1/$1 [L]
Options -Indexes
AuthName example.com
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteCond %{REQUEST_URI} !^/s1/j1/
RewriteRule (.*) /s1/j1/$1 [L] RewriteCond %{HTTP_HOST} !^www.example.com$ [NC] Options -Indexes
AuthName example.com
RewriteEngine on
RewriteCond %{THE_REQUEST} /s1/j1/
RewriteRule ^s1/j1/(.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} !^(www\.example\.com)$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteCond %{REQUEST_URI} !^/s1/j1/
RewriteRule (.*) /s1/j1/$1 [L]
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC]
RewriteRule ^(/)?$ /s1/j1/index.php [L]
Options -Indexes
RewriteEngine on
# ========= Domain example1
RewriteCond %{THE_REQUEST} /s1/j1/
RewriteRule ^s1/j1/(.*) http://www.example1.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(*\.example1\.*)$ [NC]
RewriteCond %{HTTP_HOST} !^(www\.example1\.com)$ [NC]
RewriteRule (.*) http://www.example1.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.example1.com$
RewriteCond %{REQUEST_URI} !^/s1/j1/
RewriteRule (.*) /s1/j1/$1 [L]
RewriteCond %{HTTP_HOST} ^(www.)?example1.com$ [NC]
RewriteRule ^(/)?$ /s1/j1/index.php [L]
# ========= Domain example2
RewriteCond %{THE_REQUEST} /s2/j1/
RewriteRule ^s2/j1/(.*) http://www.example2.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(*\.example2\.*)$ [NC]
RewriteCond %{HTTP_HOST} !^(www\.example2\.com)$ [NC]
RewriteRule (.*) http://www.example2.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.example2.com$
RewriteCond %{REQUEST_URI} !^/s1/j1/
RewriteRule (.*) /s2/j1/$1 [L]
RewriteCond %{HTTP_HOST} ^(www.)?example2.com$ [NC]
RewriteRule ^(/)?$ /s2/j1/index.php [L] RewriteCond %{HTTP_HOST} ^(*\.example1\.*)$ [NC]
RewriteCond %{HTTP_HOST} !^(www\.example1\.com)$ [NC]
RewriteRule (.*) http://www.example1.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} ^(www.)?example.com$ [NC]
RewriteRule ^(/)?$ /s1/j1/index.php [L]
Options -Indexes
RewriteEngine on
# ========= Domain example1
RewriteCond %{THE_REQUEST} /s1/j1/
RewriteRule ^s1/j1/(.*) http://www.example1.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(*\.example1\.*)$ [NC]
RewriteCond %{HTTP_HOST} !^(www\.example1\.com)$ [NC]
RewriteRule (.*) http://www.example1.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.example1.com$
RewriteCond %{REQUEST_URI} !^/s1/j1/
RewriteRule (.*) /s1/j1/$1 [L]
# ========= Domain example2
RewriteCond %{THE_REQUEST} /s2/j1/
RewriteRule ^s2/j1/(.*) http://www.example2.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(*\.example2\.*)$ [NC]
RewriteCond %{HTTP_HOST} !^(www\.example2\.com)$ [NC]
RewriteRule (.*) http://www.example2.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www.example2.com$
RewriteCond %{REQUEST_URI} !^/s1/j1/
RewriteRule (.*) /s2/j1/$1 [L] Other stuff later, because I gotta go clean the rat cage :(
You've got assorted domains in assorted subdirectories. Isn't there some way you can get the DNS to point directly to where each domain lives?
/userspace/
/userspace/domain1/
/userspace/domain2/
/userspace/domain3/
/domain/
/domain/otherdomain1/
/domain/otherdomain2/
Here, all requests have to pass through the first /domain/ htaccess.
In addition, the "add-on" domains can have independent htaccess files that aren't seen by any other domain.
Can't help you on cPanel, because I've got one of those mega-hosts who are so big, they made their own control panel.
And it should be a separate issue from DNS anyway. Domain names have to resolve to something-- unless, of course, you've forgotten to put a file called "index.html" in the appropriate directory. Your host may pop in a placeholder whenever you add a domain. I know mine does. (If they don't, users get that mournful browser message that says "It seems legit, but I just can't find it anywhere!")
If your structure is {primary domain plus any number of addon domains living in their separate directories}, then frankly it might be easier not to use the primary domain at all. Then you don't have to worry about conflicting RewriteRules between the outer htaccess and the inner ones.
This is a little tricky if, like most people in the world, you didn't think of making a second domain until long after the first one was established. :(
I have no use for that index.html since I don't have static pages (I removed the page). In Joomla (and most other script-based apps) it's always index.php.
It doesn't have to be .html, it just has to be index.something.
RewriteCond %{HTTP_HOST} ^(*\.example1\.*)$ [NC] is not a valid piece of code. There are multiple errors.