Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i'm trying to prepend all of my urls from to and retain the full url using mod_rewrite ad it doesn't seem to be working.


if someone goes to -, the url in the address bar should be

i moved a wordpress install to my root that was previously installed to a subdirectory with a subdomain pointing to it and want to retain my url structure for posts.


share|improve this question
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/sub
RewriteRule ^sub/(.*)$$1 [R,L]
share|improve this answer
thanks! tried this one & it gives me a 404 when i enter a link with the subdomain (i.e. - – roybatty Sep 20 '11 at 16:54
Did you configure a virtual host for – quanta Sep 20 '11 at 17:02
thanks. i'm using 1and1 shared hosting - not sure i have direct access for virtual hosts. i've setup a subdomain in the control panel that points to root. i've added this rule & i still get 404 errors. – roybatty Sep 21 '11 at 15:51
Can you point the sub domain to /document/root/sub? – quanta Sep 21 '11 at 16:04
/sub is actually a wordpress page, not a folder. in my 1and1 hosting control panel i can only point the domain to an actual folder - right now it's set to point to the root. i searched and wordpress answers here on stack exchange & couldn't find a solution. – roybatty Sep 21 '11 at 16:09
RewriteEngine On
RewriteRule ^/(.+?)/(.*)$ http://$$2 [R]
share|improve this answer
thanks for getting back. tried this & it gives me error 500. – roybatty Sep 20 '11 at 16:53
sorry try edited version – xofer Sep 20 '11 at 17:08
if it doesn't work, please post any relevant info from the error log and the full config (from apache2.conf, httpd.conf, virtual host conf file and/or .htaccess) that relates to the domain. – xofer Sep 20 '11 at 17:15
ok, i will see if i can get the log files. thanks again! – roybatty Sep 21 '11 at 15:53

Your Answer


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.