开发者

PHP Redirect handler - keep URL and URI and fetch content from another URL

开发者 https://www.devze.com 2023-03-28 04:00 出处:网络
You\'ve probably seen it on websites where they offer a website and you can use your own domain name if you want. So you register a www.website.com/user but you can also set up yourdomain.com to redir

You've probably seen it on websites where they offer a website and you can use your own domain name if you want. So you register a www.website.com/user but you can also set up yourdomain.com to redirect [with A record] to Website_IP_ADDRESS and they handle it because you gave them your domain (www.yourdomain.com) so they know to redirect to www.website.com/user but your address bar remains www.yourdomain.com

krop.com has it

This is what I've been trying to do:

PHP Redirect handler - keep URL and URI and fetch content from another URL

I want to be able to handle incoming redirects from multiple websites and 'fetch' content from a subfolder on the main site but keep the original URL intact.

I want to use php since i want to retrieve the user var (bar and foo) from a db.

Since I won't have access to every domain, I can only play with the incoming part (the blue box)

开发者_JAVA百科So far I only had success with duplicating a url (www.bar.com fetches 75.333.444.55) which is pretty useless...

And using file_get_contents('http://address') in my index.php to display subfolder index.html without redirecting again but it's slow and browser unfriendly.

I've been trying to ".htaccess it" with little success

Anything will help

Thanks


You do not want a 302 redirect! You want a virtual host.

Google for virtual host and if you need more help ask - but make sure you tell us what webserver you are using.


Thanks Ariel

here is what happened: I added the following code to /etc/httpd/conf/httpd.conf

<VirtualHost *:80>
DocumentRoot /var/www/vhosts/website.com/httpdocs/users/foo 
ServerName www.foo.com 
ServerAlias *.foo.com
</VirtualHost>

AddHandler php-script   .php

Works like charm! :)

Don't forget to restart apache to take effect. On mediatemple it is: /etc/init.d/httpd restart

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号