Problem with http / www / https and pages

amexbaczek

Registered
Jan 14, 2020
3
0
1
Poland
cPanel Access Level
Website Owner
Welcome,
I have a problem with my domain.

In .htaccess I have set http and www to redirect to as below

Apache config:
<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://

%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

</IfModule>
And now when I enter the address https://domainname.com/demo, it brings me to the Demo page

But if I enter the address https://www.domainname.com/demo or http://www.domainname.com/demo it takes me to the page https://domainname.com/index.php

How to set it to redirect to https: // after entering the address from http and / or www keeping the target page and not to the main index.php

Please help me :) PS. Sorry for my English...
 

HostNoc

Well-Known Member
Feb 20, 2020
83
12
8
Ontario
cPanel Access Level
Root Administrator
You can try this as well

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
 

amexbaczek

Registered
Jan 14, 2020
3
0
1
Poland
cPanel Access Level
Website Owner
Hello!
I'm sorry to answer so late.

Unfortunately, your suggestions do not work. Maybe because my English is poor :(

I have a page on Joomla ]\ and I have a 301 redirect from http:// | www | http:// www - and everything works fine.

But the problem is when I give the address, e.g.

https://www.domain.tld

or


or

. amex-baczek.pl/oferta/okna/okna-pvc

then he redirects me to the address: https://domain.tld/index.php

In .htaccess, I have these rules:

Apache config:
## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script
# and the requested path and file doesn't directly match a physical file
# and the requested path and file doesn't directly match a physical folder
# internally rewrite the request to the index.php script
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.
and

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
Please help me :) Thanks!
 
Last edited by a moderator: