Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I tried using the following rule:

RewriteEngine On
RewriteRule ^(.*)$ /~user/sub/index.cgi [L]

but I am getting an error. This is intended to redirect all requests within my sub/ subdirectory (which is in a web docs on a server) to a single script, but it is not working. What would the correct rule be?

Thanks!

share|improve this question
add comment

1 Answer 1

Probably:

RewriteEngine On
RewriteRule ^(.*)$ sub/index.cgi [L]

Assuming that this .htaccess file is in the root of your ~user directory.

For example, username jay:

Home directory: /home/jay
Web directory:  /home/jay/public_html (http://something/~user points here)
.htaccess file: /home/jay/public_html/.htaccess
script:         /home/jay/public_html/sub/index.cgi

Based on your comment, if your .htaccess file is in the sub directory, then you only need:

RewriteEngine On
RewriteRule ^(.*)$ index.cgi [L]
share|improve this answer
    
It's not, it's in the sub/ subdirectory. (edited to clarify) –  Peter Oct 11 '12 at 18:25
    
Then you just need to do index.cgi with nothing else. –  Jay Oct 11 '12 at 18:26
    
That does not seem to work. :( Specifically, I get a 404 error. So it is redirecting...but it must not be redirecting to the right place. –  Peter Oct 11 '12 at 18:30
    
Then it's time to get debugging. A really easy way: make your .htaccess file garbage, do you get a 500 Internal Server Error? If not, your .htaccess is not being read at all. If you get the error, you'll need to check your httpd.conf for AllowOverride. –  Jay Oct 11 '12 at 18:35
    
It is being used. I get a 500 internal server error with a bad .htaccess. And the 404 goes away when i point to an HTML file after disabling the .htaccess, but the 404 returns when I re-enable it, meaning it is being redirected after all. Just to the wrong place. Double checked spelling--index.cgi is the correct file. –  Peter Oct 11 '12 at 18:38
show 1 more comment

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.