Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

My university provides a public_html file in each student's Linux directory so tat each student can have a webpage. I want to put all my PHP scripts into that file and place the index in a sub-directory called webroot. I'm trying to work out a way to have an .htaccess file in the public_html that will redirect ALL requests in that folder to be redirected.

There's lots of advice on redirecting any file that doesn't exists but I want to redirect regardless of the existence of a file. Can I use something like RewriteCond TRUE?

share|improve this question

migrated from Sep 4 '12 at 23:16

This question came from our site for system and network administrators.

You don't need a RewriteCond, If you just have a RewriteRule it will always be executed.

Mod_Rewrite is extensively well documented, please read the friendly manual.

share|improve this answer
I've been looking through that document for a while now. /Extensive/ documentation is not always friendly for the beginner. – Matt Jun 24 '12 at 20:06
@Matt: This is a reference documentation, it needs to be complex because the topic is complex. Google is your friend for beginner tutorials. – Sven Jun 24 '12 at 20:25
@Matt While the documentation might not spoon feed it to you, as a IT Professional you are expected to be able to read and comprehend extensive and well documented systems. If you're not that kind of professional, Server Fault isn't for you (per our FAQ). – Chris S Jun 25 '12 at 2:00
My mistake then. Just seemed out of place at stackoverflow. – Matt Jun 25 '12 at 6:36

You can put this in your .htaccess file.

RewriteEngine On
RedirectMatch permanent ^~username/$

That should redirect any request for the root to your index file (not tested). Adjust to match your public_html url and domain.

share|improve this answer

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.