I know there is a few questions like this here, so forgive me for not being able to piece this together - I want a subdirectory (mainsite) to display when someone visits the root only, while the rest of the site remains as normal.
structure is:
www.mysite.com
--globalcss
--sites--mainsite--index.php
--anotherpage.php
--css--style.css
--anothersite
--anothersite
I'm also trying to get the relative css links on the mainsite index page (../../globalcss/global.css) to work once the mainsite index is displaying in the root. At one point I had the page working, but the css links were incorrectly showing as sites/mainsite/globalcss/
, ignoring the ../../
(I'd rather keep them relative if possible as my localhost root doesn't match).
Here is what I have so far:
RewriteEngine on
# attempting to get only requests in the root directory
RewriteCond %{REQUEST_URI} !(sites|globalcss)
# show the mainsite content instead
RewriteRule ^(.*)$ /sites/mainsite/$1 [L]
Thanks
So by "someone visits the root only", I assume you mean
http://www.mysite.com/
, and nothttp://www.mysite.com/anotherpage.php
. If that's the case then:If you're actually referring to anything that isn't a subdirectory, as in:
http://www.mysite.com/
is ok,http://www.mysite.com/a-file.php
is ok, buthttp://www.mysite.com/css/
should not be rewritten, then the rule needs to look like:and everything else is the same.
The way that you have your regex setup:
rewrites everything except "globalcss". And that doesn't seem to jive at all with your request that "while the rest of the site remains as normal."
The browser looks relative to the root because that's all it knows. All it knows is "I go here:
http://mysite.com/
and I see link"css/some_file.css"
, So the only thing it can do is go tohttp://mysite.com/css/some_file.css
, the browser knows nothing of all these rewrites or aliases which exists only on the server.If you want css to be able to get accessed, then you need a rule for that as well (this is really a terrible, terrible way of doing all of this):
Probably something similar to js also