Web Hosting Talk







View Full Version : mod_rewrite


roly
06-13-2002, 07:46 PM
How can I use mod_rewrite to redirect http://www.mydomain.com/forums/ to http://www.mydomain.com:8000/forums/ ?

kreativ
06-13-2002, 09:51 PM
Wouldn't this work? (in .htaccess):
Redirect /forums http://www.mydomain.com:8000/forums/

roly
06-13-2002, 09:54 PM
i don't want my users to see the :8000

Ahmad
06-13-2002, 11:01 PM
You want only the forumd directory to be served from port 8000?

roly
06-13-2002, 11:07 PM
Originally posted by Ahmad
You want only the forumd directory to be served from port 8000?
yeh

Ahmad
06-13-2002, 11:20 PM
This can only be done with application level redirection. In this kind of redirection the url with :8000 is sent to the browser, then depending on the type/version of the user agent (browser), it might or might not appear in the address bar (assuming there is an address bar in your user agent).

I once had a similar redirection for one of my forums using mod_rewrite and used Internet Explorer to visit the old addresses. Sometimes the new address would appear and sometimes the old one, and I'm not sure what decides that.

If it was a whole domain or subdomain with its own dedicated IP address, you can do that transparently by IP forwarding (network level redirection). But you want it for a single directory.

Ahmad
06-13-2002, 11:23 PM
btw, is www.mydomain.com and www.mydomain.com:8000 on the same Apache instance?

I think there is a solution, if they are.

Ahmad
06-13-2002, 11:31 PM
Try this in .htaccess:

RewriteEngine on
RewriteRule (.*) http://www.mydomain.com:8000/forums/$1

roly
06-13-2002, 11:58 PM
Originally posted by Ahmad
btw, is www.mydomain.com and www.mydomain.com:8000 on the same Apache instance?

I think there is a solution, if they are.
no
Port 80 is an Apache/1.3.19 PHP/4.0.6
Port 8000 is an Apache/1.3.24 PHP/4.2.1

priyadi
06-14-2002, 01:18 AM
If you don't want the 8080 part appears on your URL, you need to recompile the httpd on port 80 with mod_proxy included and use the following mod_rewrite statement:


RewriteEngine On
RewriteRule ^/forums/(.*)$ http://www.mydomain.com:8000/forums/$1 [P]