Forum Moderators: phranque
Let's say I have a domain called somedomain.com
There are the files for websites stored in
[somedomain.com...]
[somedomain.com...]
[somedomain.com...]
I want to be able to use those files whenever someone enters something like
[someapp1.development.somedomain.com...]
[someapp2.development.somedomain.com...]
[someapp3.development.somedomain.com...]
But I want this done with a url rewrite so I'm not always modifying httpd.conf.
Anyhelp would be great, and would the url still show what they typed, or would it show the actualy directory location?
if they try and type in the directory format of
[somedomain.com...]
Is this possible as well?
This thread [webmasterworld.com] contains a fairly good example of what you want to do. That, in combination with this Introduction to mod_rewrite [webmasterworld.com], should get you going.
You can control whether the new URL shows in the browser by using an internal (doesn't show) or external (does show) rewrite. Furthermore, you can control whether search engines retain the old URL or update their listing to use the new URL by selecting a 302 or a 301 redirect, respectively.
Jim
<VirtualHost *>
ServerName development.somedomain.ca
VirtualDocumentRoot "/var/www/htdocs/wit/development/"
ErrorLog "/var/log/apache/development.somedomain.ca.error_log"
CustomLog "/var/log/apache/development.somedomain.ca.access_log" combined
</VirtualHost>
I want to be able to make it work with *.development.somedomain.ca and the directory /var/www/htdocs/wit/development/*
How can I go about this? I'm really stumped because I allready have ALOT of vhosts defined in other ways.
I'm not any kind of httpd.conf guru. The following applies to .htaccess:
For your first post, the code would be something like this:
RewriteCond %{HTTP_HOST} ^([\.]+)\.development\.somedomain\.com
RewriteRule ^(.*)$ http://somedomain.com/development/%1/$1 [R=301,L]
If you want a temporarary redirect, change the R=301 to R=302. If you want a transparent redirect, leave the R=nnn out completely, and remove the "http://www.somedomain.com" from that line as well.
Jim