4

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?

2 Answers 2

9

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.

4
  • 3
    I've been looking through that document for a while now. /Extensive/ documentation is not always friendly for the beginner.
    – Matt
    Jun 24, 2012 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, 2012 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, 2012 at 2:00
  • My mistake then. Just seemed out of place at stackoverflow.
    – Matt
    Jun 25, 2012 at 6:36
0

You can put this in your .htaccess file.

RewriteEngine On
RedirectMatch permanent ^~username/$ http://example.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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .