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

We are on a Network Solutions VPS, four domains all one IP.

In vhost.config file for a single domain, the following will work:

Redirect 301 /1234 http://example.com/

But the following 3 rewrites will not work:

RewriteEngine On
RewriteRule ^1234$ / [R=301,L]

Options +FollowSymlinks 
RewriteEngine On
RewriteRule ^1234$ / [R=301,L]

Options +FollowSymlinks
RewriteEngine On
RewriteRule ^1234$ http://example.com [R=301,L]

These are just tests to get something more serious done with mod rewrite in vhost.config. I feel like I must just be missing something simple. If anyone can help me out, it would be greatly appreciated.

share|improve this question
2  
Have you tried adding a leading slash? i.e., RewriteRule ^/1234$? –  Andrew M. Apr 1 '11 at 12:14
    
Why would I try that ? :) Seriously thanks, works like a charm, and I appreciate the help. –  kidcobra Apr 1 '11 at 18:01
    
Yeah, Apache can be a little weird... it doesn't explicitly say it in the docs, but its one of those "gotchas" that only makes sense AFTER you figure it out. :) I added this as an answer so you can resolve the question. –  Andrew M. Apr 2 '11 at 2:29

1 Answer 1

Adding answer from my comment. Adding a leading slash makes it match the full path from the base, as opposed to a path component.

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.