Will rewrite do this?

Using a single web hosting account to host multiple sites

Will rewrite do this?

Postby binarygod » Tue Feb 03, 2009 5:59 pm

Ok, I have a hosting account with HostMonster. I have created a subdomain, namely projects.mydomain.com, this actually points to http://mydomain.com:12009/ (it's a RoR Application and they run it on a different port)

So when I goto projects.mydomain.com the address that appears in the address bar is http://mydomain.com:12009/(rest of the path if any).

Can Rewrite make it so that the address bar keeps saying project.mydomain.com/(rest of path if any)?

Here's the current rewrite rules they put in the .htaccess file for me.

RewriteCond %{HTTP_HOST} ^projects.mydomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.projects.mydomain.com$ [OR]
RewriteRule ^(.*)$ "http\:\/\/mydomain\.com\:12009\/$1"

I've tried rewriting from http:mydomain.com:12009 to projects.mydomain.com but that seems to redirect, I can't figure this out. Is there a way to show the 'pretty' url and not the base domain and port number?

Thanks
binarygod
 
Posts: 5
Joined: Tue Feb 03, 2009 5:52 pm

Postby richardk » Wed Feb 04, 2009 11:32 am

You will need mod_proxy. If you have access to the httpd.conf file it can be done with only mod_proxy or it can be done with mod_rewrite and mod_proxy
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?projects\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com:12009/$1 [P,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby binarygod » Fri Feb 06, 2009 7:32 pm

Hrmm...thanks.

I've tried that, my hoster says that mod_proxy is enabled, but what you put isn't working.

Any other suggestions?
binarygod
 
Posts: 5
Joined: Tue Feb 03, 2009 5:52 pm

Postby richardk » Sat Feb 07, 2009 12:01 pm

What happens when you go to projects.example.com?
Where have you put the mod_rewrite?
Does it work (redirect) if you replace the P with an R?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby binarygod » Sat Feb 07, 2009 1:20 pm

When I go to the adress I get a 404 error.

I have no idea where the mod_rewrite is, it's a shared hoster so they have it installed someplace

It does work if I replace the P with an R, it just make the URL ugly is all.
binarygod
 
Posts: 5
Joined: Tue Feb 03, 2009 5:52 pm

Postby binarygod » Sat Feb 07, 2009 3:19 pm

Ok, so I did some snooping around in my log files and found this:

Attempt to serve directory: proxy:http://mydomain.com:12009/

So it appears like it's working, but for some reason the proxy isn't seeing the Mongrel Ruby on Rails server at that port or something...and ideas?
binarygod
 
Posts: 5
Joined: Tue Feb 03, 2009 5:52 pm

Postby richardk » Mon Feb 09, 2009 8:37 am

have no idea where the mod_rewrite is, it's a shared hoster so they have it installed someplace

I meant where are you putting
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?projects\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com:12009/$1 [P,L]

but it does not matter now.

It does work if I replace the P with an R, it just make the URL ugly is all.

That shows that the problem is not the mod_rewrite.

So it appears like it's working, but for some reason the proxy isn't seeing the Mongrel Ruby on Rails server at that port or something...and ideas?

I do not. Can you proxy to other places? Try google.com.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby binarygod » Mon Feb 09, 2009 12:02 pm

Thanks for all the help richard, I finally got somebody that knew what they where talking about and found out that mod_proxy is disabled.

So I apologize for wasting your time.
binarygod
 
Posts: 5
Joined: Tue Feb 03, 2009 5:52 pm


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 2 guests

cron