Проблема с WWW -> non-WWW redirect

Тема в разделе "Общие вопросы", создана пользователем Elias, 6 окт 2015.

  1. Zlata Jesen

    Zlata Jesen Продвинутый пользователь

    Сообщения:
    165
    Симпатии:
    98
    Да точно тот, я txt и .htaccess не перепутаю.
    Сам текст:

    Код:
    # 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
    
    # 2. In your opencart directory rename htaccess.txt to .htaccess.
    
    # For any support issues please visit: http://www.opencart.com
    
    Options +FollowSymlinks
    
    # Prevent Directoy listing
    Options -Indexes
    
    # Prevent Direct Access to files
    <FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
    Order deny,allow
    Deny from all
    </FilesMatch>
    
    # SEO URL Settings
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    
    #RewriteCond %{SERVER_PORT} !^443$
    #RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
    # 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 ^yandexbuy/([^?]*)$ index.php?route=yandexbuy/$1 [L,QSA]
    RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
    RewriteRule ^googlebase.xml$ index.php?route=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]
    
    Redirect 301 /Radar-Detector http://ms-autotech.ru/avtoelectronika/Radar-Detector
    
    ### 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
    
    Уже давно на хостинге не правлю, только скачиваю и в notepad'е.
    Кстати редирект Redirect 301 /Radar-Detector... и т.д. работает, перекидывает.
     
  2. Ален

    Ален Эксперт

    Сообщения:
    2.056
    Симпатии:
    640
    я неправильно написал, обычно после RewriteBase / ставят правила.

    дальше по редиректу, попробуйте это
    Код:
    RewriteCond %{HTTP_HOST} !^sait\.ru [NC]
    RewriteCond %{HTTP_HOST} !=""
    RewriteRule ^(.*)$ http://sait.ru/$1 [R=301,L]
    И если сообщение не помогло, уберите пожалуйста лайки... а то людям трудно ориентироваться в полезности сообщения.
     
  3. Zlata Jesen

    Zlata Jesen Продвинутый пользователь

    Сообщения:
    165
    Симпатии:
    98
    То есть вообще без указания www?
    Попробовала. Не помогает.
    Поставила после RewriteBase / перед RewriteRule ^yandexbuy/
     
  4. solunski.d

    solunski.d Эксперт

    Сообщения:
    1.569
    Симпатии:
    432
    Обращались к хостингу?
     
  5. Zlata Jesen

    Zlata Jesen Продвинутый пользователь

    Сообщения:
    165
    Симпатии:
    98
    Сейчас уже пишу тикет...
     
  6. Zlata Jesen

    Zlata Jesen Продвинутый пользователь

    Сообщения:
    165
    Симпатии:
    98
    Заработало в формате:

    Код:
    RewriteCond %{HTTP_HOST} ^www.сайт\.ru$ [NC]
    RewriteRule ^(.*)$ http://сайт.ru/$1 [R=301,L]
    Вот уж не знаю, чем он отличается от тех, что выше... может где точки лишние были или пробелы? Там же каждый значок важен.
    Всё равно всем большое спасибо за поддержку! :)
     
    Romans и solunski.d нравится это.
  7. Alex_2015

    Alex_2015 Новичок

    Сообщения:
    19
    Симпатии:
    0
    Была такая проблема, поставил сразу же после RewriteBase / и всё ок
     
    Последнее редактирование: 6 мар 2017
  8. igor11

    igor11 Пользователь

    Сообщения:
    33
    Симпатии:
    1
    Появилась недавно: не работает переадресация с www на без www. Вроде раньше все в порядке было.

    Вот файл .htaccess:
    Код:
    # 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
    
    # 2. In your opencart directory rename htaccess.txt to .htaccess.
    
    # For any support issues please visit: http://www.opencart.com
    
    Options +FollowSymlinks
    
    # Prevent Directoy listing
    Options -Indexes
    
    
    php_value max_input_vars 15000
    
    
    # Prevent Direct Access to files
    <FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
     Order deny,allow
     Deny from all
    </FilesMatch>
    
    <IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^bizarreshop\.by$ [NC]
    RewriteRule ^(.*)$ https://bizarreshop.by/$1 [R=301,L]
    </IfModule>
    
    <FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
      Header set Cache-Control "max-age=2592000"
    </FilesMatch>
    
    # SEO URL Settings
    RewriteEngine On
    # 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=feed/fast_sitemap [L]
    RewriteRule ^sitemap2.xml$ index.php?route=feed/google_sitemap [L]
    RewriteRule ^rss.xml$ http://feeds.feedburner.com/bizarreshop [L]
    RewriteRule ^googlebase.xml$ /index.php?route=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]
    
    <IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www.bizarreshop.by$ [NC]
    RewriteRule ^(.*)$ http://bizarreshop.by/$1 [R=301,L]
    </IfModule>
    
    
    # сжатие text, html, javascript, css, xml:
    <ifModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
    </ifModule>
    
    
    ### 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
    
    Подскажите в чём дело.
     
    Последнее редактирование модератором: 6 сен 2017
  9. karpov

    karpov Продвинутый пользователь

    Сообщения:
    1.519
    Симпатии:
    241
    Может кеш.. проверяйте в режиме инкогнито.
    Сайт у вас вообще не работает.
     
  10. igor11

    igor11 Пользователь

    Сообщения:
    33
    Симпатии:
    1
    Разобрался, вот исправленное.
    Код:
    # 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
    
    # 2. In your opencart directory rename htaccess.txt to .htaccess.
    
    # For any support issues please visit: http://www.opencart.com
    
    Options +FollowSymlinks
    
    # Prevent Directoy listing
    Options -Indexes
    
    
    php_value max_input_vars 15000
    
    
    # Prevent Direct Access to files
    <FilesMatch "(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))">
    Order deny,allow
    Deny from all
    </FilesMatch>
    
    <FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
    Header set Cache-Control "max-age=2592000"
    </FilesMatch>
    
    # SEO URL Settings
    RewriteEngine On
    # If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/
    
    RewriteBase /
    # с www на без www
    RewriteCond %{HTTP_HOST} ^www.bizarreshop.by$ [NC]
    RewriteRule ^(.*)$ http://bizarreshop.by/$1 [R=301,L]
    RewriteRule ^sitemap.xml$ index.php?route=feed/fast_sitemap [L]
    RewriteRule ^sitemap2.xml$ index.php?route=feed/google_sitemap [L]
    RewriteRule ^rss.xml$ http://feeds.feedburner.com/bizarreshop [L]
    RewriteRule ^googlebase.xml$ /index.php?route=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]
    # с http на https - варианты просмотреть из инструкции ниже
    RewriteCond %{HTTP_HOST} !^bizarreshop\.by$ [NC]
    RewriteRule ^(.*)$ https://bizarreshop.by/$1 [R=301,L]
    
    # сжатие text, html, javascript, css, xml:
    <ifModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
    </ifModule>
    
    
    ### 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
    
     
    Последнее редактирование модератором: 6 сен 2017