www.domain.com/folder/file.php => sub.domain.com/file.php

Using a single web hosting account to host multiple sites

www.domain.com/folder/file.php => sub.domain.com/file.php

Postby DarkPepe » Wed Oct 15, 2008 12:58 pm

Hi, Im looking for a way to convert :

www.domain.com/folder/file.php => sub.domain.com/file.php

I havent found any example for this on the forums after searching for quite a while, I'll apreciate some help.

Thank you.
DarkPepe
 
Posts: 11
Joined: Thu Dec 14, 2006 11:25 pm

Postby richardk » Thu Oct 16, 2008 6:30 am

Do you want the sub domain in the browser's address bar?
Does the sub domain exist? What happens when you got to the sub domain?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby DarkPepe » Thu Oct 16, 2008 8:08 am

richardk wrote:Do you want the sub domain in the browser's address bar?
Does the sub domain exist? What happens when you got to the sub domain?


The subdomain exists, but it does not matters if its shown on the address bar.

I moved my store catalog out of my main site and created a stand alone sub domain for it.

the old address was: http://www.madboxpc.com/catalogo/index.php

the new one is: http://catalogo.madboxpc.com/index.php


Thanxs.
DarkPepe
 
Posts: 11
Joined: Thu Dec 14, 2006 11:25 pm

Postby richardk » Fri Oct 17, 2008 8:31 am

Oh, so you want to redirect users to the new URL (the sub domain).

Try this in a .htaccess file in madboxpc.com's document root
Code: Select all
Redirect 301 /catalogo http://catalogo.madboxpc.com
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby DarkPepe » Fri Oct 17, 2008 9:17 am

richardk wrote:Oh, so you want to redirect users to the new URL (the sub domain).

Try this in a .htaccess file in madboxpc.com's document root
Code: Select all
Redirect 301 /catalogo http://catalogo.madboxpc.com


I allready have something like that on a php header, I need a rewrite rule to not loose all the links ppl have posted over the net poiting a particular product of my catalog for example:

http://www.madboxpc.com/catalogo/produc ... ts_id=2821

wich used to exists and now is a 404, needs to be rewriten to:

http://catalogo.madboxpc.com/product_in ... ts_id=2821

Thnk you very much.
DarkPepe
 
Posts: 11
Joined: Thu Dec 14, 2006 11:25 pm

Postby richardk » Fri Oct 17, 2008 2:09 pm

I would have thought a redirect from the old URL to the new URL would be best.

So you want the old URLs to still work without a redirect. Is the sub domain and the main domain on the same server? What are their document roots?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby DarkPepe » Fri Oct 17, 2008 2:54 pm

richardk wrote:I would have thought a redirect from the old URL to the new URL would be best.

So you want the old URLs to still work without a redirect. Is the sub domain and the main domain on the same server? What are their document roots?


The are on different servers, the document roots are the same, but on different machines:

www.madboxpc.com/catalogo (server 1):

/home/madbox/public_html/catalogo (empty directory now)

and for the new one catalogo.madboxpc.com (server 2):

/home/madboxpc/public_html/catalogo (wich contains the catalog website now)

Thank you.
DarkPepe
 
Posts: 11
Joined: Thu Dec 14, 2006 11:25 pm

Postby richardk » Sat Oct 18, 2008 3:58 am

For the old URLs to stay the same you will need mod_proxy, in a .htaccess file in madboxpc.com/.htaccess
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^catalogo(/(.*))?$ http://catalogo.madboxpc.com/$2 [P,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby DarkPepe » Mon Oct 20, 2008 1:50 pm

richardk wrote:For the old URLs to stay the same you will need mod_proxy, in a .htaccess file in madboxpc.com/.htaccess
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^catalogo(/(.*))?$ http://catalogo.madboxpc.com/$2 [P,L]


Thank you very much, this solution works, the only problem is related with the url, since it shows the old www.madboxpc.com/catalogo/xxxx.php url instead of http://catalogo.madboxpc.com/xxxx.php in the address bar and somehow, some of the functions of the catalog script dont work without the defined new url (catalogo.madbox....)

To solve this I need mod proxy? I dont understand that part.

Thank you again.
DarkPepe
 
Posts: 11
Joined: Thu Dec 14, 2006 11:25 pm

Postby DarkPepe » Mon Oct 20, 2008 2:06 pm

mhm nevermind.. I solved it with the first redirect code you gave me!

Thank you so much!
DarkPepe
 
Posts: 11
Joined: Thu Dec 14, 2006 11:25 pm


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 6 guests

cron