I could use some help with mod_rewrite for apache. My new web host puts all of the sub domains in a folder under the doc root of the main site, I want to effectively move the main site's doc root down a folder, I know this can be done with mod_rewrite and a rewrite rule but I am not sure exactly how to do it. I basically want to rewrite all url's in a host to a folder other than the current one, can anyone help me with this?

Thanks,
Glenn

EDIT: would this work?
Quote:
RewriteRule $1 /foldername/$1
No, that wouldn't work. mod_rewrite uses regular expressions to filter what it should rewrite and how to do it.

Code:
RewriteRule ^(.*)$ subdirectory/$1 [L]

What's it do? Filters for any number of any character [.*], groups that string into something you can reference in the replacement expression [(.*)], and wraps it in the magic start/end characters (^(.*)$]. The [L] signals to mod_rewrite that it should stop rewriting if the input url matches this one.

If you don't know regular expressions, I highly recommend learning.
The Tari wrote:
No, that wouldn't work. mod_rewrite uses regular expressions to filter what it should rewrite and how to do it.

Code:
RewriteRule ^(.*)$ subdirectory/$1 [L]

What's it do? Filters for any number of any character [.*], groups that string into something you can reference in the replacement expression [(.*)], and wraps it in the magic start/end characters (^(.*)$]. The [L] signals to mod_rewrite that it should stop rewriting if the input url matches this one.

If you don't know regular expressions, I highly recommend learning.


This is still now working, 500 error pages, any ideas? I will be in IRC and for speed lets try to discuss there for a little bit.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement