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'm trying to prepend all of my urls from mysite.com/sub to sub.mysite.com and retain the full url using mod_rewrite ad it doesn't seem to be working.

example

if someone goes to - mysite.com/sub/1/2/3, the url in the address bar should be sub.mysite.com/1/2/3

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.

thanks!

share|improve this question

2 Answers 2

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/sub
RewriteRule ^sub/(.*)$ http://sub.mysite.com/$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. - sub.mysite.com/1/2/3) –  roybatty Sep 20 '11 at 16:54
    
Did you configure a virtual host for sub.mysite.com? –  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 wordpress.org and wordpress answers here on stack exchange & couldn't find a solution. –  roybatty Sep 21 '11 at 16:09
RewriteEngine On
RewriteRule ^/(.+?)/(.*)$ http://$1.mysite.com/$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

 
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.