Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a server running on XAMPP in LAN.

In htdocs I've created subfolder called 'apps' (it's because I'm using one CodeIgniter's files to multiple webpages).

Now, when somenone want to visit a webpage, must visit: http://myserver/apps/app_name.

Is it possible with .htaccess (or else) to skip that /apps/ part? http://myserver/app_name ?

share|improve this question
up vote 4 down vote accepted

Activate mod_rewrite, and put this in a .htaccess file or a <Directory> directive:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_URI} !^apps/
RewriteRule (.*) apps/$1

What it does:

The first three lines check if the requested URI refers to an actually existing file, directory or link, in order to make sure that e.g. an index.html at top level is still delivered if requested.

The fourth line makes sure that the user has not already requested an URI in the apps/ subpath.

If the requested URI is not an existing file, directory or link and does not start with apps/, the path of the URL is taken and apps/ is prepended. This only happens internally.

share|improve this answer
thanks for your help. I have last one questions. How to hide that /app/ part from url? – breq Jun 4 '14 at 6:20
It should not be visible, if you just enter http://yoursite.com/foobar, as the rewriting to http://yoursite.com/apps/foobar is only done internally. If you want to redirect all paths starting with apps/ to strip that part, this rule should do, if placed before the other ones: RewriteRule ^apps/(.*)$ $1 [R=301,QSA,L]. It does a 301-redirect, you can change the http status code by changing the R=301. The QSA appends any parameters the original URL had to the new URL, and the L stops further rewriting the request after that rule in order to send out the redirect to the browser. – Jost Jun 4 '14 at 9:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.