Support

Admin Tools

#16911 Redirect to Subdomain

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by user55161 on Wednesday, 31 July 2013 08:39 CDT

user55161
Mandatory information about my setup:

Have I read the related troubleshooter articles above before posting (which pages?)? Yes
Have I searched the tickets before posting? Yes
Have I read the documentation before posting (which pages?)? Yes
Joomla! version: 2.5.11
PHP version: 5.3.25
MySQL version: (unknown)
Host: unlimitedwebhosting
Admin Tools version: 2.5.6 Pro

Description of my issue:

I am moving a website to a new server using Akeeba Backup. All is well. Before I change nameservers (the site is currently being accessed by an entry in the hosts file). I'd like to configure a subdomain

For the old site, there was no subdomain. The site was accessed via a subfolder:

http://mydomain.com/oldfolder

For the transferred site there is now a subdomain:

http://subdomain.mydomain.com
On the server the files for this exist in a new folder:

http://mydomain.com/newfolder

This means changing the entries in .htaccess maker from "oldfolder" to newfolder". However, what I want is to redirect everyhting for this site to http://subdomain.mydomain.com
Without doubt I must change the "Ssytem Configuration" section at the bottom of the .htaccess maker page. But to force access via the subdomain...
a) I could use Joomla's native redirect component
b) I could use Admin Tools' redirect component
c) It's likely I could use a URL rewrite in .htaccess maker

a) or b) will require two entries (to cope with the legacy urls out there):
http://mydomain.com/oldfolder --> http://subdomain.mydomain.com
AND
http://mydomain.com/newfolder --> http://subdomain.mydomain.com

Is this the right way to do it or should this best be done through .htaccess?
If the latter what should I do and where?

Thanks,
Ric

nicholas
Akeeba Staff
Manager
Hello Ric,

You need to pursue option C, a custom URL rewrite in a .htaccess file. Please note that this file must be placed in the root of the mydomain.com, NOT the subdomain. Remember that you want to redirect visitors to a subdirectory of the main site to the root of the subdomain. Nothing running or living inside your new site (in the subdomain) will be called when a user tries to access a subdirectory in the main site.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user55161
good stuff!

Then I'm thinking of these two entries in .htaccess:

RewriteRule ^oldfolder/(.*)$ http://subdomain.domain.com/$1 [R=301,L]
RewriteRule ^newfolder/(.*)$ http://subdomain.domain.com/$1 [R=301,L]

Do these look OK?
..and place them.. in "Custom .htaccess rules at the top of the file" or "Custom .htaccess rules at the bottom of the file"?

Regards,
Ric

nicholas
Akeeba Staff
Manager
Yes, these look OK. But as I said:

Please note that this file must be placed in the root of the mydomain.com, NOT the subdomain. Remember that you want to redirect visitors to a subdirectory of the main site to the root of the subdomain. Nothing running or living inside your new site (in the subdomain) will be called when a user tries to access a subdirectory in the main site.


As a result you can't use .htaccess Maker because it will only generate a .htaccess file inside the subdomain, not the main domain's root.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user55161
Yes, I knew I'd miss something out in trying to simplify things...

The main site runs Joomla; so does the subdomain. The two are entirely separate sites, one being a public site; the subdomain being a private members' site. Both have Admin Tools, so I can use the one in the root domain.

Having given you the full picture, does is matter where: "Custom .htaccess rules at the top of the file" or "Custom .htaccess rules at the bottom of the file"?

Regards,
Ric

nicholas
Akeeba Staff
Manager
Aaah! Now it makes sense again :) Yes, add this to the "Custom .htaccess rules at the top of the file" in .htaccess Maker of the main site.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user55161
Thank you for the above.

I'm looking at the "System Configuration" section of the SUBDOMAIN in .htaccess maker. I'm not quite sure what these entries are intended to do...

The old values (old sever) are:
HTTPS requests: domain.com/oldfolder
HTTP requests: domain.com/oldfolder
Follow symlinks: No
Base directory of your site: oldfolder

These will need to be replaced with the new values. I think there are two choices:
HTTPS requests: subdomain.domain.com
HTTP requests: subdomain.domain.com
Follow symlinks: No
Base directory of your site: /

OR:

HTTPS requests: domain.com/newfolder
HTTP requests: domain.com/newfolder
Follow symlinks: No
Base directory of your site: newfolder

2nd one does not look correct because the subdomain is not in a subfolder of the main domain (Plesk: subdomain in a folder in its own right).

Thanks again,
Ric

Postscript: tried the former and I get a 404 error. not sure though if that's because I'm using an IP override in hosts... If I look in Joomla's core redirect I see entries for oldfolder; oldfolder/; newfolder.

Looks like none of them are redirecting. Cleared the cache too.

Tried suspending the .htaccess in the subdomain. No effect. Still get the 404 not found

nicholas
Akeeba Staff
Manager
Correct settings for the subdomain:

HTTPS requests: subdomain.domain.com
HTTP requests: subdomain.domain.com
Follow symlinks: No
Base directory of your site: /

Make sure the $live_site in your configuration.php is either blank or set to 'http://subdomain.domain.com'

Also note that some of your links may be pointing to /oldfolder/something.html instead of just plain something.html. This is the result of relative URLs when having a site in a subdirectory. There is a workaround in Admin Tools: SEO & Link Tools, set "Enable link migration" to Yes and in the "Old locations (domain names)" below enter (one item per line):
domain.com/oldfolder
/oldfolder

using the real domain and old folder names, of course. Can you guess why I wrote that feature? :)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user55161
For the subdomain...

System Configuration was already set as you advised.

$live_site = ''

changed to: $live_site = 'http://subdaomain.domain.com';

added to SEO:
domain.com/oldfolder
/oldfolder

I'm still getting that 404: not found.

Something wierd about the server configuration maybe?

Ric

nicholas
Akeeba Staff
Manager
It seems that it's something in the server setup.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user55161
This is very frustrating... but not the end of the world. Fortunately this site is for private members and, until it is fixed, they are going to have to remember the new URL.

I'll contact the server people. That's when nailing jelly to the tree really starts :)

Ric

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!