forumer
Осваиваюсь на форуме
 
Репутация: +0/-0
Offline
Сообщений: 53
|
 |
« : 02.02.2012, 13:33:21 » |
|
Мне необходимо склеить зеркала сайтов (www.site.ru и site.ru) на Joomla 1.7.3. Помогите настроить 301-й редирект. Я прописываю в .htaccess редирект на сайт без www: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^www.site.ru [NC] RewriteRule ^(.*) http://site.ru/$1 [L,R=permanent]
Но теперь, если перейду на любую страницу с www, то попадаю всегда только на одну страницу: site.ru/index.php
Как Вы делаете редирект на\с www? Работает ли он у Вас? Может ли это быть по вине хостера?
|
|
|
|
« Последнее редактирование: 02.02.2012, 15:15:46 от forumer »
|
Записан
|
|
|
|
|
vtx
|
 |
« Ответ #1 : 02.02.2012, 13:36:04 » |
|
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
|
|
|
|
|
Записан
|
|
|
|
forumer
Осваиваюсь на форуме
 
Репутация: +0/-0
Offline
Сообщений: 53
|
 |
« Ответ #2 : 02.02.2012, 13:44:35 » |
|
vtx, Ваш редирект даёт тот же самый результат: все страницы с www у меня редиректятся только на одну страницу site.ru/index.php
|
|
|
|
« Последнее редактирование: 02.02.2012, 14:10:38 от forumer »
|
Записан
|
|
|
|
|
vtx
|
 |
« Ответ #3 : 02.02.2012, 14:03:02 » |
|
попробуйте закоментировать RewriteBase /, если поможет поставте в конце этого правила.
|
|
|
|
|
Записан
|
|
|
|
forumer
Осваиваюсь на форуме
 
Репутация: +0/-0
Offline
Сообщений: 53
|
 |
« Ответ #4 : 02.02.2012, 14:10:02 » |
|
Пробовал эту директиву комментировать, разкомменитировать, ставить в конец файла - не помогает
|
|
|
|
|
Записан
|
|
|
|
|
oriol
|
 |
« Ответ #5 : 02.02.2012, 14:14:24 » |
|
########## Begin - Redirect www to non-www ## WARNING: Comment out the non-www to www rule if you choose to use this RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] ## If the above throws an HTTP 500 error, swap [R=301,L] with [R,L] ########## End - Redirect non-www to www или тебе надо добавить www ? тогда так ########## Begin - Redirect non-www to www RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] ## If the above throws an HTTP 500 error, swap [R=301,L] with [R,L] ########## End - Redirect non-www to www только предыдущий редирект закоментируй
|
|
|
|
« Последнее редактирование: 02.02.2012, 14:33:13 от oriol »
|
Записан
|
|
|
|
forumer
Осваиваюсь на форуме
 
Репутация: +0/-0
Offline
Сообщений: 53
|
 |
« Ответ #6 : 02.02.2012, 14:27:31 » |
|
oriol, и Ваш вариант даёт тот же рузультат. Кстати, пробовал тестить на денвере - получаю тоже самое: site/index.php Не понимаю, почему не работает редирект?
|
|
|
|
|
Записан
|
|
|
|
|
oriol
|
 |
« Ответ #7 : 02.02.2012, 14:36:37 » |
|
Напиши конкретно что тебе надо ?
|
|
|
|
|
Записан
|
|
|
|
forumer
Осваиваюсь на форуме
 
Репутация: +0/-0
Offline
Сообщений: 53
|
 |
« Ответ #8 : 02.02.2012, 14:45:21 » |
|
Я же описал суть проблемы в первом посте. Ладно, пишу снова, другими словами: Мне нужен редирект 301 без www. Я прописываю его (пробовал все выше предложенные варианты) в .htaccess, после чего если захожу на какую-нибудь страницу с www, то редирект выполняется не на эту же страницу без www, а на страницу site.ru/index.php
Как сделать редирект, чтобы пользователь переадрисовывался на адрес без www, а не только на одну страницу index.php?
|
|
|
|
|
Записан
|
|
|
|
|
vtx
|
 |
« Ответ #9 : 02.02.2012, 14:50:29 » |
|
прилепите свой htaccess
|
|
|
|
|
Записан
|
|
|
|
|
oriol
|
 |
« Ответ #10 : 02.02.2012, 14:56:27 » |
|
Ага чет там нах....вертил и пойми че там не работает  у всех как надо а у него ......... Если с другого домина так пиши что с другого домена
|
|
|
|
« Последнее редактирование: 02.02.2012, 14:59:49 от oriol »
|
Записан
|
|
|
|
forumer
Осваиваюсь на форуме
 
Репутация: +0/-0
Offline
Сообщений: 53
|
 |
« Ответ #11 : 02.02.2012, 15:00:22 » |
|
Это htaccess ## # @version $Id: htaccess.txt 21101 2011-04-07 15:47:33Z dextercowley $ # @package Joomla # @copyright Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved. # @license GNU General Public License version 2 or later; see LICENSE.txt ##
## # READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE! # # The line just below this section: 'Options +FollowSymLinks' may cause problems # with some server configurations. It is required for use of mod_rewrite, but may already # be set by your server administrator in a way that dissallows changing it in # your .htaccess file. If using it causes your server to error out, comment it out (add # to # beginning of line), reload your site in your browser and test your SEF url's. If they work, # it has been set by your server administrator and you do not need it set here. ##
## Can be commented out if causes errors, see notes above. Options +FollowSymLinks
## Mod_rewrite in use.
RewriteEngine On
## Begin - Rewrite rules to block out some common exploits. # If you experience problems on your site block out the operations listed below # This attempts to block the most common type of exploit `attempts` to Joomla! # # Block out any script trying to base64_encode data within the URL. RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR] # Block out any script that includes a <script> tag in URL. RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR] # Block out any script trying to set a PHP GLOBALS variable via URL. RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] # Block out any script trying to modify a _REQUEST variable via URL. RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) # Return 403 Forbidden header and show the content of the root homepage RewriteRule .* index.php [F] # ## End - Rewrite rules to block out some common exploits.
## Begin - Custom redirects # # If you need to redirect some pages, or set a canonical non-www to # www redirect (or vice versa), place that code here. Ensure those # redirects use the correct RewriteRule syntax and the [R=301,L] flags. # ## End - Custom redirects
## # Uncomment following line if your webserver's URL # is not directly related to physical file paths. # Update Your Joomla! Directory (just / for root). ##
# RewriteBase /
## 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 RewriteCond %{REQUEST_URI} !^/index\.php # and the request is for something within the component folder, # or for the site root, or for an extensionless URL, or the # requested URL ends with one of the listed extensions RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC] # and the requested path and file doesn't directly match a physical file RewriteCond %{REQUEST_FILENAME} !-f # and the requested path and file doesn't directly match a physical folder RewriteCond %{REQUEST_FILENAME} !-d # internally rewrite the request to the index.php script RewriteRule .* index.php [L] # ## End - Joomla! core SEF Section.
Вот htaccess:
########## Begin - Redirect www to non-www ## WARNING: Comment out the non-www to www rule if you choose to use this RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] RewriteRule ^(.*)$ http://%1/$1 [R=301,L] ## If the above throws an HTTP 500 error, swap [R=301,L] with [R,L] ########## End - Redirect non-www to www
|
|
|
|
|
Записан
|
|
|
|
|
vtx
|
 |
« Ответ #12 : 02.02.2012, 15:01:45 » |
|
поставь правило сразу после RewriteEngine On
|
|
|
|
|
Записан
|
|
|
|
|
oriol
|
 |
« Ответ #13 : 02.02.2012, 15:08:09 » |
|
это для себя они написали ? ## Begin - Custom redirects # # If you need to redirect some pages, or set a canonical non-www to # www redirect (or vice versa), place that code here. Ensure those # redirects use the correct RewriteRule syntax and the [R=301,L] flags. # ## End - Custom redirects # # Начало - Пользовательские перенаправления # # Если вам нужно перенаправить некоторые страницы или установить канонические без WWW на # WWW редиректа (или наоборот), место, код здесь. Обеспечить эти # Перенаправления использовать правильный синтаксис и RewriteRule [R = 301, L] флаги. # # # End - Custom перенаправления
именно в этой части
|
|
|
|
|
Записан
|
|
|
|
forumer
Осваиваюсь на форуме
 
Репутация: +0/-0
Offline
Сообщений: 53
|
 |
« Ответ #14 : 02.02.2012, 15:09:33 » |
|
oriol, домен тот же самый. Речь идёт только о www. Объясняю на примере: Ставлю 301 редирект с www.site.ru на site.ru. Ввожу в браузуре, например, www.site.ru/page1 меня редиректит на site.ru/index.php А должно редиректить на site.ru/page1 На всех сайтах жJoomla 1.7.3 такой редирект, на денвере установил чистую Joomla тоже самое. В чём может быть проблема?
|
|
|
|
|
Записан
|
|
|
|
forumer
Осваиваюсь на форуме
 
Репутация: +0/-0
Offline
Сообщений: 53
|
 |
« Ответ #15 : 02.02.2012, 15:14:51 » |
|
vtx, oriol, спасибо за решённый вопрос. Заработало! Просто в прошлых версиях Joomla не важно было, где ставить редирект в htaccess.
|
|
|
|
|
Записан
|
|
|
|
|