e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
318 stars 212 forks source link

siteredirection is not working for www version #5097

Open Jimmi08 opened 7 months ago

Jimmi08 commented 7 months ago

Bug Description

if you set redirection on, it doesn't work for siteurl with www prefix

How to Reproduce

Steps to reproduce the behavior:

  1. set e_DOMAIN in e107_config.php
  2. set siteurl with www version
  3. site URL redirection ON
  4. test both versions - both works (www and non-www), there is not redirection

Expected Behavior

Site redirection to www version. It works with https and htttp.

Additional Information

The reason is here: if (($urlport !== $PrefSitePort || stripos($PrefSiteBase, $urlbase) === false ) && strpos(e_REQUEST_SELF, ADMINDIR) === false)

In my case: $PrefSiteBase - www.hpfanfiction.cz $urlbase -hpfanfiction.cz stripos($PrefSiteBase, $urlbase) = 4 - so that check fails

Thanks

Jimmi08 commented 3 weeks ago

A possible solution, not tested, just note

            list($PrefSiteBase,$PrefSitePort) = explode(':',$PrefRoot.':');
            $PrefSiteBase = str_replace("www.", '', $PrefSiteBase);