Y
Y
ygen2021-09-30 22:56:10
htaccess
ygen, 2021-09-30 22:56:10

How to setup .htaccess redirect with CNC?

Hello.
Do not tell me, there is a line like:

RewriteRule ^([a-zA-Z0-9_-]+)/?([a-zA-Z0-9_-]*)/?([0-9]*)/?( [a-zA-Z0-9:;_-]*)/?$ /index.php?action=$1¶m=$2&page_num=$3&option=$4

But when accessing www, the address becomes:
https://site. ru//index.php/product-name/?action=ca...

When accessing the site, everything is fine:
https://site.ru/catalog/product-name/

Can you help solve the problem? Thank you.

The file itself:

RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [NC,R=301,L]
RewriteCond %{HTTP_HOST} ^www.site.ru$ [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
RewriteRule ^([a-zA-Z0-9_-]+)/?([a-zA-Z0-9_-]*)/?([0-9]*)/?([a-zA-Z0-9:;_-]*)/?$ /index.php?action=$1&param=$2&page_num=$3&option=$4

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zettabyte, 2021-10-01
@Zettabyte

Firstly, this line seems to contain an error: Must be (with an exclamation mark), otherwise I don't understand the meaning of this redirect - it should be a check for an http connection (lack of https in the URL). In addition, check how it will work if you replace these linesRewriteCond %{HTTPS} on

RewriteCond %{HTTP_HOST} ^www.site.ru$ [NC]
RewriteRule ^(.*)$ https://site.ru/$1 [R=301,L]
on the
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]

This is a redirect to a URL without "www.".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question