PHPfox-Official / phpfox-v4-issues

phpFox Public Bug Tracker
https://phpfox.com
30 stars 21 forks source link

www not working #2992

Closed PENTAGON4 closed 3 years ago

PENTAGON4 commented 3 years ago

Important

Please follow this template!


What's happened?

I have www. in my url. However, the non-www version is still accessible for some reason. This makes the login/register modal not work and makes some of the icons appear as a box with an "X" in it.

Steps to reproduce:

  1. Have $_CONF['core.host'] = 'www.mysite.com'; in server.sett.php
  2. https is enabled with both settings Secure Image Display and Secure Pages with HTTPS
  3. non-www site still accessible by typing https://mysite.com
  4. Tried adding this to .htaccess file in publi_html folder:
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

What's expected?

Redirect to www. site every time

Browsers and Devices tested

(Example: Chrome on iPhone X, Safari on Macbook, Miscrosoft Edge on Windown 10, Firefox on Ubuntu 16.04, ...)

Edge

Server information

(Example: CentOS 7, php 7.1 apache)

Cloudlinux 7.9

phpFox version

(Example: phpFox 4.6.0)

phpfox 8.3

Screenshots

...

spirogg commented 3 years ago

first in .htaccess remove whatever rule your trying to use to redirect we can do it all in cpanel and it wiil work. i use cPanel as well with another server :)

go into your main cPanel and look under domains. and click on Domains

you will see Force HTTPS redirect : there is a swith you click on to turn that on. will turn blue means its on

then click the top left (cPanel) logo again to return to your main cPanel and then under domains> you will see Redirects (click on that)

when on that page it gives you options :

1st option TYPE:

you will keep on Permenant 301

next option: https?://(www.)?

select your domain name

next option: Redirects to

type in: http://www.yourdomain.com

(notice use http://www. not https://www. ;because we already setup https redirect under domains earlier)

next option: select> Do Not Redirect www. ;

(because we are redirecting too www so no need to use a redirect if someone types in www.yourdomain.com)

and then click ADD

now your all set..

depending on your browser you can refresh a few times and when you try to use http://yourdomain.com you will redirect to https://www.yourdomain.com even if you type yourdomain.com will always redirect first to https and al;ways use www. ;

PS make sure when you install phpfox.xom script you must install from https://www.yourdomain.com becasue if you use anything else you will have issues loggin in and with images.. etc.. you have to install phpfox in a certain way either www. or no www and that is how your redirect needs to be.

So I always used https://www.mydomian.com when installing phpfox, after I had setup my redirect setup as the directions above in cPanel

then i uploaded phpfox script and typed in the browser https://www.mydomain.com and started the installation this way. then when everything is done you will have no erros and be able to use www. always as its going to be setup this way from the start :)

hope this helps you and others.

kind regards,

Spiro

spirogg commented 3 years ago

if you have cPanel and don't want to go through the redirect just make sure you go into your main cPanel and look under domains. and click on Domains icon.

you will then see Force HTTPS redirect : there is a switch you click on to turn that on. will turn blue (which means its forcing https)

then go to .htaccess file and add to the top and save.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain\.com$
RewriteRule ^/?$ "http\:\/\/www\.yourdomain\.com\/" [R=301,L]
PENTAGON4 commented 3 years ago

Thanks. I ended up using a redirect.

I was apprehensive of using the redirect because I created a wrong redirect. It gave an error and said there were too many redirects. I'm using the redirect now after you posted this solution. Thanks again!