CMS in subdirectory, how to hide it from users?

I installed my CMS into a subdirectory, because it came out of the box that way. If I had known better, I would have installed it directly into public_html but it’s too late now.

I want to completely hide the subdirectory from users (using .htaccess in public_html), because (a) I don’t want anyone to know which CMS I’m using, (b) the CMS has a really dumb name that I want to hide, and (c) it just looks better.

I know I’ve done this before with other websites, but I can’t find the magical code snippet after searching for over an hour. The best I’ve found so far has been this:

RewriteCond %{REQUEST_URI} !subdir/
RewriteRule (.*) http://example.com/subdir/$1 [L]

This works…halfway. It redirects the front page to /subdir, but any links from the front page have /subdir in them. No good. I want /subdir to disappear completely from all URLs.

I also tried:

DocumentRoot /subdir

but I just get 500 internal server error, “/home/username/public_html/.htaccess: DocumentRoot not allowed here”

This is something you have to do yourself; Apache won’t change links in the HTML it sends to browsers. It’s probably a setting in your CMS somewhere.

Anyway, what’s the problem with moving directories around so your CMS directory becomes your public_html/ directory? It’s a lot simpler and doesn’t cause Apache to rewrite all the time. Which doesn’t take up a lot of time, but it does take ~some~ time which can be easily avoided if you just move stuff around. You can than 301 redirect everything from subdir/ to / to indicate to SEs that it has moved, and you’re all set :slight_smile:

vellocet,

Rémon is correct and all you will need to do is change the CMS’s configuration file (assuming it’s WordPress or similar CMS - they all work the same way!). Overall, it’s a trivial solution.

Regards,

DK

#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?lilpitt.com$
RewriteCond %{REQUEST_URI} !^/lilpitt/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /lilpitt/$1
RewriteCond %{HTTP_HOST} ^(www.)?lilpitt.com$
RewriteRule ^(/)?$ lilpitt/ [L]

lilpitt.com is my url n need be replaced… n other “lilpitt” is folder in dir

Focus,

Is there a question in that? I see several possible problems with your code:

  1. dot characters are not escaped in regex

  2. domain name is not No Case

  3. the first RewriteRule is ANDED with the following RewriteCond (no Last flag)

  4. lots of code but no question.

Regards,

DK