Grouping Redirects By Domain

Helicon Ape provides support for Apache .htacces and .htpasswd configuration files for Microsoft IIS.
User avatar
Posts: 4
Joined: 08 Aug 2014, 14:43

Grouping Redirects By Domain

08 Aug 2014, 14:51

When setting up redirects with helicon ape for a CMS that has multiple domain names that pull up different contect, is there a way in the .htaccess file to group statements. For example, on a site with a CMS installed, I have the following domains setup:

domaina.com
domainb.com

Currently if I want to put in different redirect rules for each domain, I have to do something like:

RewriteCond %{HTTP_HOST} ^www.domaina.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domaina.com$ [NC]
RewriteRule ^SomePathToLookFor$ / [R=301,NC,L]

RewriteCond %{HTTP_HOST} ^www.domaina.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domaina.com$ [NC]
RewriteRule ^SomeDifferentPathToLookFor$ /go/here [R=301,NC,L]

RewriteCond %{HTTP_HOST} ^www.domainb.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domainb.com$ [NC]
RewriteRule ^PathToLookFor$ /this/is/where/you/go [R=301,NC,L]

RewriteCond %{HTTP_HOST} ^www.domainb.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domainb.com$ [NC]
RewriteRule ^NewPathToLookFor$ /go/here/instead [R=301,NC,L]

It would be nice if I could do something like:

RewriteCond %{HTTP_HOST} ^www.domaina.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domaina.com$ [NC]
{
RewriteRule ^SomePathToLookFor$ / [R=301,NC,L]
RewriteRule ^SomeDifferentPathToLookFor$ /go/here [R=301,NC,L]
}

RewriteCond %{HTTP_HOST} ^www.domainb.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domainb.com$ [NC]
{
RewriteRule ^PathToLookFor$ /this/is/where/you/go [R=301,NC,L]
RewriteRule ^NewPathToLookFor$ /go/here/instead [R=301,NC,L]
}

Is there a way to implement something like this in helicon ape so I can group all the redirect rules for specific domains into one group. It would make it easier to manage as well as reduce the size of the .htaccess file.

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Grouping Redirects By Domain

11 Aug 2014, 14:19

Hello,

As far as I understand, you put all these rules into httpd.conf file.
In this case you can use <VirtualHost> sections to group rules like this:

<VirtualHost www.domaina.com domaina.com>
RewriteEngine On
RewriteRule ^SomePathToLookFor$ / [R=301,NC,L]
RewriteRule ^SomeDifferentPathToLookFor$ /go/here [R=301,NC,L]
</VirtualHost>

<VirtualHost www.domainb.com domainb.com>
RewriteEngine On
RewriteRule ^PathToLookFor$ /this/is/where/you/go [R=301,NC,L]
RewriteRule ^NewPathToLookFor$ /go/here/instead [R=301,NC,L]
</VirtualHost>

User avatar
Posts: 4
Joined: 08 Aug 2014, 14:43

Re: Grouping Redirects By Domain

18 Aug 2014, 12:30

This is for Helicon Ape on a windows server and we cannot update the httpd.conf file which is for Apache. The following does not appear to work in the .htaccess file:

<VirtualHost www.domaina.com domaina.com>
RewriteEngine On
RewriteRule ^SomePathToLookFor$ / [R=301,NC,L]
RewriteRule ^SomeDifferentPathToLookFor$ /go/here [R=301,NC,L]
</VirtualHost>

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: Grouping Redirects By Domain

19 Aug 2014, 09:06

Hello,

"This is for Helicon Ape on a windows server and we cannot update the httpd.conf file which is for Apache."
- sorry, didn't quite understand you. Both httpd.conf and .htaccess are using in Helicon Ape as well as in Apache. You are using Helicon Ape, right? Why would you need to use VirtualHost directive in .htaccess which is already a per-site configuration file? Simply put the rules for domain A into .htaccess in the root of domainA and the rules for domain B into the .htaccess in the root of domainB.

User avatar
Posts: 4
Joined: 08 Aug 2014, 14:43

Re: Grouping Redirects By Domain

08 Sep 2014, 14:22

The issue is that the this is for a CMS which has multiple domain portals on it. The CMS knows which site to pull up based on the domain that was provided. In this case, there are 4 domain names that point to different portals within the same CMS. We are wanting to be able to group the redirect rules by domain in the .htaccess file so the redirects for 1 domain will not effect the other domains.

User avatar
Posts: 4
Joined: 08 Aug 2014, 14:43

Re: Grouping Redirects By Domain

17 Sep 2014, 11:17

Does anyone know if this is possible with the current Helicon Ape? I can open a paid support ticket if that will help get an answer or a fix for what I am trying to do....

Return to Helicon Ape

Who is online

Users browsing this forum: No registered users and 39 guests