Forum Moderators: phranque

Message Too Old, No Replies

URL Rewrite

yet another q

         

Gibble

7:39 pm on May 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need to solve an .htaccess URL issue I'm having.

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?

Gibble

7:45 pm on May 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would also like for it to redirect people to
[someapp1.development.somedomain.com...]

if they try and type in the directory format of

[somedomain.com...]

Is this possible as well?

jdMorgan

7:45 pm on May 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Gibble,

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

Gibble

8:09 pm on May 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



woah, Umm...actually after reading the apache document I'm thinking using a VirtualDocumentRoot would be simpler, but I allready have a bunch of VirtualHosts defined...man I'm confused as to how to add this.

Gibble

8:25 pm on May 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, here is the vhost entry I have

<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.

jdMorgan

8:35 pm on May 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Gibble,

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]

Your second post reverses this, so it would create an infinite loop.

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

Gibble

8:54 pm on May 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Unfortunately I don't have RewriteEngine abilities...that sucks, but I should be able to do this with httpd.conf