L
L
Lici2014-06-16 14:28:06
PHP
Lici, 2014-06-16 14:28:06

Why doesn't ReDirect work when the server response is 301?

Domain:
www.tkstour.com
tkstour.com
A domain with www gives a 301 server response code, but if you access it from a browser, the page is simply not available. You can see for yourself.

Response code
HTTP/1.1 301 Moved Permanently
Server: nginx/1.0.15
Date: Mon, 16 Jun 2014 11:19:40 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: keep-alive
Location: tkstour.com

I wrote the following code in .htaccess:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST}	^www\.(.*)	[NC]
RewriteRule ^(.*)$ http://%1/$1	[R=301,L]

Basically, I have this file:
.htaccess
#order deny,allow
#deny from all
AddDefaultCharset UTF-8
ErrorDocument 404 /404
ErrorDocument 401 /password.php
RewriteEngine on
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Админка теперь по адресу /simpla
RewriteRule ^admin/?$ simpla [L]
# Каталог товаров
RewriteRule ^catalog/([^/]+)/?$ index.php?module=ProductsView&category=$1 [L,QSA]
RewriteRule ^catalog/([^/]+)/([^/]+)/?$ index.php?module=ProductsView&category=$1&brand=$2 [L,QSA]
RewriteRule ^products/([^/]+)/?$ index.php?module=ProductView&product_url=$1 [L,QSA]
RewriteRule ^products/?$ index.php?module=ProductsView [L,QSA]
RewriteRule ^brands/([^/]+)/?$ index.php?module=ProductsView&brand=$1 [L,QSA]
RewriteRule ^brands/([^/]+)/page_([^/]+)/?$ index.php?module=ProductsView&brand=$1&page=$2 [L,QSA]
# Поиск товаров
RewriteRule ^search/([^/]+)/?$ index.php?module=ProductsView&keyword=$1 [L,QSA]
RewriteRule ^search/?$ index.php?module=ProductsView [L,QSA]
# Блог
RewriteRule ^blog/([^/]+)/?$ index.php?module=BlogView&url=$1 [L,QSA]
RewriteRule ^blog/category/([^/]+)/?$ index.php?module=BlogView&cat=$1 [L,QSA]
RewriteRule ^blog/?$ index.php?module=BlogView [L,QSA]
# Корзина и заказы
RewriteRule ^cart/?$ index.php?module=CartView [L,QSA]
RewriteRule ^cart/([^/]+)/?$ index.php?module=CartView&add_variant=$1 [L,QSA]
RewriteRule ^cart/remove/([^/]+)/?$ index.php?module=CartView&delete_variant=$1 [L,QSA]
RewriteRule ^order/([^/]+)/?$ index.php?module=OrderView&url=$1 [L,QSA]
RewriteRule ^order/?$ index.php?module=OrderView [L,QSA]
# Для пользователей
RewriteRule ^user/login/?$ index.php?module=LoginView [L,QSA]
RewriteRule ^user/register/?$ index.php?module=RegisterView [L,QSA]
RewriteRule ^user/logout/?$ index.php?module=LoginView&action=logout [L,QSA]
RewriteRule ^user/password_remind/?$ index.php?module=LoginView&action=password_remind [L,QSA]
RewriteRule ^user/password_remind/([0-9a-z]+)/?$ index.php?module=LoginView&action=password_remind&code=$1 [L,QSA]
RewriteRule ^user/?$ index.php?module=UserView [L,QSA]
# Google sitemap
RewriteRule ^sitemap.xml?$ sitemap.php [L,QSA]
# XML
RewriteRule ^yandex.xml?$ yandex.php [L,QSA]
RewriteRule ^google.xml?$ google.php [L,QSA]
# feedback
RewriteRule ^contact/?$ index.php?module=FeedbackView [L,QSA]
#downloads
RewriteRule ^order/([^/]+)/([^/]+)/?$ index.php?module=OrderView&url=$1&file=$2 [L,QSA]
#Карта
RewriteRule ^map/?$ index.php?module=MapView [L,QSA]
#сравнение товаров
RewriteRule ^collate/?$ index.php?module=CollateView [L,QSA]
# Статические страницы
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/?$ index.php?module=PageView&page_url=$1 [L,QSA]
RewriteRule ^/?$ index.php?module=MainView&page_url= [L,QSA]
# Ресайз картинок на лету
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^files/products/(.+) resize/resize.php?file=$1&token=%{QUERY_STRING}
#RewriteCond %{THE_REQUEST} ^GET\ (.*)files/products/(.*)\?([A-z0-9]*)
#RewriteRule ^files/products/(.+) resize/resize.php?file=%2&token=%3 [L,NE]

I tried other spellings of the rule, but the result is always the same. What can be wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2014-06-16
@merryjane

Try clearing your browser cache.
In mozilla and chrome everything redirected from www to "no www".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question