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 had http://example.com/intranet/ which I had to turn into http://intranet.example.com Unfortunately, everything was written with the absolute path so its like <a href="/intranet/timeclock">time clock</a>

So you see my dilemma. everything wants to go to like /intranet/timeclock

I tried some rewrite rules like

    RewriteRule ^/intranet / [R,L]
    RewriteRule ^/intranet/(*.) /$1 [R,L]

And others. No luck. I have looked at the other posts on server fault and tried some of them with no luck either. Andy advice?

share|improve this question
    
Can you, please, clearly describe what you want to rewrite: from => to. Do you want to rewrite http://intranet.example.com/ into http://example.com/intranet/ ... or? –  LazyOne Jul 13 '11 at 21:25
    
I would like "intranet.example.com/intranet/timeclock"; to rewrite to "intranet.example.com/timeclock"; –  hforbess Jul 14 '11 at 12:36
    
MrTuttle already gave an answer (301 Permanent Redirect). If you place his rule into Apache config file (inside <VirtualHost>, for example) it should work fine. If you are going to place it into .htaccess file, then you should remove leading slash /. The same goes for your own rules -- in .htaccess there is no leading slash when pattern is applied to URL in RewriteRule. –  LazyOne Jul 14 '11 at 12:42
add comment

1 Answer

up vote 1 down vote accepted

RewriteEngine On

RewriteRule ^/intranet/(.*)$ http://intranet.example.com/$1 [R=301,L]

share|improve this answer
    
thats seems like it would work but it does nothing. Am i doing something wrong with the .htaccess file i wonder? –  hforbess Jul 14 '11 at 12:46
    
Thats it! only its RewriteRule ^intranet/(.*)$ intranet.example.com/$1 [R=301,L] –  hforbess Jul 14 '11 at 12:59
add 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.