Помощь с htaccess для сайта


Niraban
 Поделиться

Рекомендуемые сообщения

Всем доброго времени суток. В виду собственной тупости и неосведомленности в работе с htaccess прошу помочь в его правильном составлении)

Файл был доработан фрилансером и передан мне как готовый к работе. Но, как показала практика и подсказали здесь же на форуме добрые люди, он неправильный.

 

Сайт недавно переехал на https. Хостер: ukraine*com*ua. С существующим htaccess многие страницы отдаются по http или много раз редиректятся.

Если у Вас есть корректный файл htaccess или можете указать, где его взять - буду рад любой помощи)

Свой же прилагаю ниже.

 

Заранее благодарен за помощь всем неравнодушным к чужому горю:)))

9.txt

Ссылка на комментарий
Поделиться на других сайтах

35 минут назад, Niraban сказал:

доброго времени суток.

 

1) Заливаете тот который из сборки оригинальный.
2) Идёте в тему переезда на https: 

3) Делаете как там сказано.

4) Профит =)

Ссылка на комментарий
Поделиться на других сайтах

4 часа назад, Niraban сказал:

на https. Хостер: ukraine*com*ua.

Вот мой рабочий .htaccess  на этом хостере:

Скрытый текст

# Options +FollowSymlinks
Options +SymLinksIfOwnerMatch

# Prevent Directoy listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
 Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# Order deny,allow
# Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
<IfModule mod_rewrite.c>
    RewriteCond %{QUERY_STRING} (eval\() [NC,OR]
    RewriteCond %{QUERY_STRING} (javascript:)(.*)(;) [NC,OR]
    RewriteCond %{QUERY_STRING} (base64_encode)(.*)(\() [NC,OR]
    RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC,OR]
    RewriteCond %{QUERY_STRING} (<|%3C)(.*)script(.*)(>|%3) [NC,OR]
    RewriteCond %{QUERY_STRING} (\\|\.\.\.|\.\./|~|`|<|>|\|) [NC,OR]
    RewriteCond %{QUERY_STRING} (boot\.ini|etc/passwd|self/environ) [NC,OR]
    RewriteCond %{QUERY_STRING} (\'|\")(.*)(drop|insert|md5|select|union) [NC]
    RewriteRule .* - [F]
</IfModule>
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations
# php_admin_value open_basedir none

 

 

Ссылка на комментарий
Поделиться на других сайтах

@WarStyle, @kimono11, большое спасибо за помощь! Назрел встречный вопрос: так как стоковый htaccess с добавлениями двух строк для хоста ukraine и предложенный вариант в готовом виде малость отличаются......как проверить какой из них для меня будет корректным?)

Ссылка на комментарий
Поделиться на других сайтах

5 часов назад, Niraban сказал:

@WarStyle, @kimono11, большое спасибо за помощь! Назрел встречный вопрос: так как стоковый htaccess с добавлениями двух строк для хоста ukraine и предложенный вариант в готовом виде малость отличаются......как проверить какой из них для меня будет корректным?)

Скрытый текст

# Options +FollowSymlinks (это в стоковом)

Options +SymLinksIfOwnerMatch (так должно быть для нашего хостинга, иначе ошибка 500) (эту конструкцию нам менять не нужно, т.к. у нас apache свежее чем 2.2. Вам сделали как для старых версий. Важно это или нет подскажут гуру, я не очень шарю)

<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">

# Prevent Direct Access to files Require all denied #

# For apache 2.2 and older, replace "Require all denied" with these two lines :

# Order deny,allow

# Deny from all

</FilesMatch>

# SEO URL Settings

RewriteEngine On (Эти две строки отвечают за редирект с www/на без www. И с http/на https. Пробовал разные варианты по инструкции, конкретно у меня на нашем хосте работает так.)

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]

RewriteRule ^(.*)$ https://%1/$1 [R=301,L] (это делал по мануалу Устранение критических уязвимостей магазинов )

<IfModule mod_rewrite.c>

RewriteCond %{QUERY_STRING} (eval\() [NC,OR]

RewriteCond %{QUERY_STRING} (javascript:)(.*)(;) [NC,OR]

RewriteCond %{QUERY_STRING} (base64_encode)(.*)(\() [NC,OR]

RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC,OR]

RewriteCond %{QUERY_STRING} (<|%3C)(.*)script(.*)(>|%3) [NC,OR]

RewriteCond %{QUERY_STRING} (\\|\.\.\.|\.\./|~|`|<|>|\|) [NC,OR]

RewriteCond %{QUERY_STRING} (boot\.ini|etc/passwd|self/environ) [NC,OR]

RewriteCond %{QUERY_STRING} (\'|\")(.*)(drop|insert|md5|select|union) [NC]

RewriteRule .* - [F]

</IfModule>

Изменено пользователем RHCk
Картинки, логи и код убирайте под спойлер.
Ссылка на комментарий
Поделиться на других сайтах

3 минуты назад, kimono11 сказал:

 


# Options +FollowSymlinks (это в стоковом)
Options +SymLinksIfOwnerMatch (так должно быть для нашего хостинга, иначе ошибка 500)

# Prevent Direct Access to files (эту конструкцию нам менять не нужно, т.к. у нас apache свежее чем 2.2. Вам сделали как для старых версий. Важно это или нет подскажут гуру, я не очень шарю)
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
 Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# Order deny,allow
# Deny from all
</FilesMatch>

# SEO URL Settings (Эти две строки отвечают за редирект с www/на без www. И с http/на https. Пробовал разные варианты по инструкции, конкретно у меня на нашем хосте работает так.)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

<IfModule mod_rewrite.c> (это делал по одному из мануалов по оптимизации в блоге Yoda ) 
    RewriteCond %{QUERY_STRING} (eval\() [NC,OR]
    RewriteCond %{QUERY_STRING} (javascript:)(.*)(;) [NC,OR]
    RewriteCond %{QUERY_STRING} (base64_encode)(.*)(\() [NC,OR]
    RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC,OR]
    RewriteCond %{QUERY_STRING} (<|%3C)(.*)script(.*)(>|%3) [NC,OR]
    RewriteCond %{QUERY_STRING} (\\|\.\.\.|\.\./|~|`|<|>|\|) [NC,OR]
    RewriteCond %{QUERY_STRING} (boot\.ini|etc/passwd|self/environ) [NC,OR]
    RewriteCond %{QUERY_STRING} (\'|\")(.*)(drop|insert|md5|select|union) [NC]
    RewriteRule .* - [F]
</IfModule>

Ну это расписано прям для меня....для того, "кто ездит на бронепоезде"))

Ссылка на комментарий
Поделиться на других сайтах

В 29.06.2017 at 07:41, kimono11 сказал:

Вот мой рабочий .htaccess  на этом хостере:

  Показать содержимое


# Options +FollowSymlinks
Options +SymLinksIfOwnerMatch

# Prevent Directoy listing
Options -Indexes

# Prevent Direct Access to files
<FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
 Require all denied
## For apache 2.2 and older, replace "Require all denied" with these two lines :
# Order deny,allow
# Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
<IfModule mod_rewrite.c>
    RewriteCond %{QUERY_STRING} (eval\() [NC,OR]
    RewriteCond %{QUERY_STRING} (javascript:)(.*)(;) [NC,OR]
    RewriteCond %{QUERY_STRING} (base64_encode)(.*)(\() [NC,OR]
    RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC,OR]
    RewriteCond %{QUERY_STRING} (<|%3C)(.*)script(.*)(>|%3) [NC,OR]
    RewriteCond %{QUERY_STRING} (\\|\.\.\.|\.\./|~|`|<|>|\|) [NC,OR]
    RewriteCond %{QUERY_STRING} (boot\.ini|etc/passwd|self/environ) [NC,OR]
    RewriteCond %{QUERY_STRING} (\'|\")(.*)(drop|insert|md5|select|union) [NC]
    RewriteRule .* - [F]
</IfModule>
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

# 7. disable open_basedir limitations
# php_admin_value open_basedir none

 

 

 

Сделано по по аналогу Вашего htaccess. В итоге при переходе на 2-ю, 3-ю и т.д. страницу пагинации в URL автоматом включается сортировка

mysite.com/ru/katalog/category/#/sort=p.sort_order/order=ASC/limit=15/page=2

 

У Вас так же?

Ссылка на комментарий
Поделиться на других сайтах

7 часов назад, Niraban сказал:

У Вас так же?

у меня все нормально, страницы такого вида:

https://mycoolcafe.com/desktops/?page=2

Ссылка на комментарий
Поделиться на других сайтах

7 часов назад, kimono11 сказал:

у меня все нормально, страницы такого вида:

https://mycoolcafe.com/desktops/?page=2

Понял. Буду искать варианты. Видимо, фильтр у меня привередливый к этим правилам. Буду искать решение.

Ссылка на комментарий
Поделиться на других сайтах

Присоединяйтесь к обсуждению

Вы можете опубликовать сейчас и зарегистрироваться позже. Если у вас есть учётная запись, войдите, чтобы публиковать под своей учётной записью.

Гость
Ответить в тему...

×   Вы вставили отформатированное содержимое.   Удалить форматирование

  Разрешено не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Показать вместо этого как ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Нельзя вставлять изображения напрямую. Загрузите или вставьте изображения по URL.

 Поделиться