.htaccess - alias all www-only requests to subdirectory
Posted
by
CodeMoose
on Stack Overflow
See other posts from Stack Overflow
or by CodeMoose
Published on 2013-07-01T22:43:12Z
Indexed on
2013/07/01
23:05 UTC
Read the original article
Hit count: 178
.htaccess
Trying to install the wonderful Concrete5 CMS to use as my main site engine - the problem is it has about 15 different files and directories, and they clutter up my root. I'd really like to move it to a /_concrete/
subdirectory, and still maintain it in the domain root.
htaccess has never been my strong suit - after a lot of research and learning, and a lot of error 500s, my frustration is overriding my pride and I'm posting here. Here's exactly what I'm trying to accomplish:
- Any requests that come through
www.domain.com
are forwarded towww.domain.com/_concrete/
, except in the case of an existing file. - The end-user URL shouldn't change - they will still see the site as
www.domain.com
, even though they're being servedwww.domain.com/_concrete/
. - Multiple subdomains exist on this site as sub-folders within the root - thus, only requests coming through
www.domain.com
should be redirected.
Here's the closest I got with my htaccess, which produces an error 500:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !^_concrete
RewriteRule ^(.*)$ _concrete/$1 [L,QSA]
This is the result of 4 hours of sweat and blood (mostly blood), so I have to be close. I'm hoping one of your fine minds can point out a stupid mistake and put this thing to rest swiftly. Thanks for your time!
Addendum: I previously posted .htaccess - alias domain root to subfolder a while ago, which got me started. Please don't fall into the trap of thinking it's a duplicate.
© Stack Overflow or respective owner