Support

Admin Tools

#9695 Redirect non-www to www not working properly

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 nicholas on Thursday, 18 November 2010 23:42 CST

user20478
Thought I'd start a new thread since it's a different problem I am having :)

My site site looks like this: www.example.com/uk, I am using the redirect from non-www to www feature in Admin Tools.
The redirection removes the /uk when I skip writing www, redirecting it to www.example.com, without the /uk. Same if I go to example.com/uk/forum, it redirects to www.example.com/forum, again stripping only the /uk part.

Is there a way to fix this please? Would be very appreciated :)

Thanks in advance,

user20478
Ok I fixed this aswell :P

In this section of .htaccess:

##### Redirect non-www to www -- BEGIN
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R,L]
##### Redirect non-www to www -- END

I added my /uk to make it look like this:

##### Redirect non-www to www -- BEGIN
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/uk/$1 [R,L]
##### Redirect non-www to www -- END

Am I supposed to do this or have I missed some setting in the .htaccess Maker? :)

Anyway my site is working great now, with redirection aswell :)

Thanks for a great software!

nicholas
Akeeba Staff
Manager
Normally the $1 part of the rule should instruct Apache's mod_rewrite to automatically pick the path and query string after the domain name and append it to the www domain. Which version of Apache are you using?

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!

user20478
Hi thanks for replying, I had to ask my hosting provider for the version, this is what they said:

"Server version: Apache/2.2.16 (Unix)
Mod_rewrite has been compiled by default on your server"

I also realize that I now have to add /uk every time I create a new .htaccess file, which is quite annoying :P Is there a way for me to solve this?

I tried disabling the rewrite and instead adding the code in the custom .htaccess rules section, but it would only redirect me to www.example.com/uk/index.php. I guess it needs to be called before some other line of code, which makes it impossible for me to add it to the custom section as it only allows me to put it either at the very top or bottom.

Any help is appreciated!

Thanks in advance,

nicholas
Akeeba Staff
Manager
You can do a very easy workaround. First, disable now www to www redirection. Then, place this code at the custom .htaccess code to place at the top of your file:
 RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/uk/$1 [R,L] 


This should do the trick :)

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!

user20478
Thanks, will try it!

I thought if I put it at top it would be called before this:
##### RewriteEngine enabled - BEGIN
RewriteEngine On
##### RewriteEngine enabled - END

doesn't it need to be called after that? :)

user20478
Update: It works now :) And I noticed it does not get put at the *very* top of the file, it's below the RewriteEngine On :)

Thanks for your help! :D

nicholas
Akeeba Staff
Manager
It's put in there on purpose, in order to cater for cases like yours ;)

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!

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!