简体   繁体   中英

Redirect in php or htaccess from incoming url

I am new to this forum and I have a pretty straight forward question. I have a site www.mysite.com that is the main site with all content. Upon this I have like 20 different domains and now I would like to add domain pointers so all these domains points to the main site. I know how to do this but I would like to define somewhere in the root catalog of the www.mysite.com where these domains shall be redirected to. For example:

domainA.com -> mysite.com/lures
domainB.com -> mysite.com/bait/worms
domainC.com -> mysite.com
domainD.com -> mysite.com/lines/braids
etc....

Is this best done in htaccess file or in a php file or in the index.php file? I am using Joomla 3.x for all my sites. Thanks.

You can use .htaccess file for this.

It will be something like:

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST}   domainA.com
RewriteRule ^/(.*)  http://example.com/lures

This should work.

Also you can do external redirect ( http://example.com/lures ) or internal redirect where user will still see domainA.com in a browser but , http://example.com/lures page is visible.

This looks like the best solution, as I am a newbie when it comes to this kid of coding how do I set up multiple domains, like this?

    RewriteEngine On RewriteBase /  
RewriteCond %{HTTP_HOST} domainA.com
RewriteRule ^/(.*) example.com/lures 
RewriteCond %{HTTP_HOST} domainB.com
RewriteRule ^/(.*) example.com/bait/worms 
RewriteCond %{HTTP_HOST} domainC.com 
RewriteRule ^/(.*) example.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM