logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Configuring Apache2 separate domain to a dynamic homepage
Author
Beyondhelp



Joined: 04 Sep 2023
Posts: 5
Location: London

PostPosted: Wed 13 Sep '23 16:20    Post subject: Configuring Apache2 separate domain to a dynamic homepage Reply with quote

Hi all,

Can just about get my way round apache2, but I can't get this to work.

I have a few domains a.com b.com c.com

a.com is the sites root directory. This works fine.

I want domains b.com and c.com to point to other dynamic pages within a.coms domain, so that if you goto b.com you are essentially taken to another area on he same site as a.com.

Any help would be hugely appreciated.
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 312
Location: UK

PostPosted: Wed 13 Sep '23 17:59    Post subject: Reply with quote

Believe you need to explain precisely what you mean by "dynamic pages".

Presumably, the DocumentRoot settings for b.com and c.com differ to that for a.com, and yet you want parts of those sites to be served by content from a.com?

So within Apache, could you use Alias or AliasMatch directives within those domains (vhosts?), to pick up content from the directory structure for a.com?

See https://httpd.apache.org/docs/current/mod/mod_alias.html for details and examples.
Back to top
Beyondhelp



Joined: 04 Sep 2023
Posts: 5
Location: London

PostPosted: Thu 14 Sep '23 3:28    Post subject: Reply with quote

Please excuse me if I use incorrect terminology I just mean pages on a Joomla site.

I'll try and explain again.

a.com is the main site home page/document root. Within the a.com are a load of pages that can be viewed as a.com/topic_b/

I just want b.com to treat a.com/topic_b/ as its document root.

I tried setting up a complete virtual server config and used topic_b as the document root but it doesn't work as strictly speaking a.com/topic_b is dynamic so it would be a.com/index.php/topic_b.php but that doesn't work either.

The alternative could be a b.com redirect to a.com/topic_b/ but google/bing wont index that as its a redirection.
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 312
Location: UK

PostPosted: Thu 14 Sep '23 22:14    Post subject: Reply with quote

Ok, so your site content is being dynamically generated by Joomla CMS code, and you want some content overlap across differing domains using Apache.

I'd definitely start with a virtual host for each domain, each with a separate document root, and work from there. I tried the following basic configuration in a test environment, using local host file entries for a.com and b.com.

The Alias directive in the second vhost duly mapped requests for http://b.com to the content below C:/Apache24/htdocs/a.com/topic_b/

Code:
<VirtualHost *:80>
    DocumentRoot "C:/Apache24/htdocs/a.com"
    ServerName a.com
    <Directory "C:/Apache24/htdocs/a.com">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "C:/Apache24/htdocs/b.com"
    ServerName b.com

    <Directory "C:/Apache24/htdocs/b.com">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    Alias "/" "C:/Apache24/htdocs/a.com/topic_b/"

    <Directory "C:/Apache24/htdocs/a.com">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Is this the sort of functionality you're trying to achieve?
Back to top
Beyondhelp



Joined: 04 Sep 2023
Posts: 5
Location: London

PostPosted: Fri 15 Sep '23 0:15    Post subject: Reply with quote

I'm going to give this a go and report back.

Thanks Smile
Back to top
Beyondhelp



Joined: 04 Sep 2023
Posts: 5
Location: London

PostPosted: Fri 15 Sep '23 0:54    Post subject: Reply with quote

So it comes up with file not found when trying to call topic_b.html, so www.a.com/topic_b which works but calling it via Alias "/" "/var/www/a/topic_b.html" shows file not found.

If I test that location by actually creating a real topic_b.html it does load it fine. So it seems that its pointing to the right place just not loading a dynamic page.
Back to top
Beyondhelp



Joined: 04 Sep 2023
Posts: 5
Location: London

PostPosted: Fri 15 Sep '23 1:13    Post subject: Reply with quote

Ok I think I've found a suitable solution.

Using the virtual server config for b.com I've added this:

RewriteEngine on
RewriteRule ^/$ /topic_b/ [R]

So now going to b.com shows b.com/topic_b/ as the landing page which as long as it gets picked up by google etc properly, is totally fine.
Back to top


Reply to topic   Topic: Configuring Apache2 separate domain to a dynamic homepage View previous topic :: View next topic
Post new topic   Forum Index -> Apache