Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 serverfault.com Sep 4 '12 at 23:16

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

2 Answers 2

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
1  
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. –  SvW 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/$ http://mydomain.com/~username/php/index.php

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

/ Michael

share|improve this answer

Your Answer

 
discard

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.