V1rTu
@V1rTu
начинающий веб-программист

Bitrix: Проблема с urlwrite.php?

Добрый день. Возник вопрос: Как сделать обработку со слешом (/) и без, для страниц через urlwrite.php?

К примеру:
Существует сайт host.ru/project - отлично переходит в index.ph
если набрать host.ru/project попадает на 404.

Нужно чтобы и со слешем (/) на конце и без переправляло на нормальный index.php

Ниже поле кода=( не знаю как спойлер сделать!
Обработка без слеша идет почти в самом конце.

<?
$arUrlRewrite = array(
	array(
		"CONDITION"	=>	"#^/projects/([-a-z0-9]+)/gallery/([0-9]+)#",
		"RULE"	=>	"ID=$1&SECT=$2",
		"ID"	=>	"",
		"PATH"	=>	"/projects1/gallery2.php",
	),
	array(
		"CONDITION"	=>	"#^/projects/([-a-z0-9]+)/gallery+([^\\?]*)([\\s\\S]*)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/projects1/gallery.php",
	),
	array(
		"CONDITION"	=>	"#^/projects/([-a-z0-9]+)/sales+([^\\?]*)([\\s\\S]*)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/projects1/sales.php",
	),
	array(
		"CONDITION"	=>	"#^/house-projects/([-a-z0-9]+)/gallery/([0-9]+)#",
		"RULE"	=>	"ID=$1&SECT=$2",
		"ID"	=>	"",
		"PATH"	=>	"/house-projects1/gallery2.php",
	),
	array(
		"CONDITION"	=>	"#^/projects/([-a-z0-9]+)/map+([^\\?]*)([\\s\\S]*)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/projects1/map.php",
	),
	array(
		"CONDITION"	=>	"#^/zhilye-kompleksy/([-a-z0-9]+)/map+([^\\?]*)([\\s\\S]*)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/livecomplex/map.php",
	),
	array(
		"CONDITION"	=>	"#^/townhouses/([-a-z0-9]+)/map+([^\\?]*)([\\s\\S]*)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/townhouses1/map.php",
	),
	array(
		"CONDITION"	=>	"#^/zhilye-kompleksy/([-a-z0-9]+)/credit+([^\\?]*)([\\s\\S]*)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/livecomplex/credit.php",
	),
	array(
		"CONDITION"	=>	"#^/townhouses/([-a-z0-9]+)/credit+([^\\?]*)([\\s\\S]*)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/townhouses1/credit.php",
	),
	array(
		"CONDITION"	=>	"#^/zhilye-kompleksy/([-a-z0-9]+)/gallery/([0-9]+)#",
		"RULE"	=>	"ID=$1&SECT=$2",
		"ID"	=>	"",
		"PATH"	=>	"/livecomplex/gallery2.php",
	),
	array(
		"CONDITION"	=>	"#^/townhouses/([-a-z0-9]+)/gallery/([0-9]+)#",
		"RULE"	=>	"ID=$1&SECT=$2",
		"ID"	=>	"",
		"PATH"	=>	"/townhouses1/gallery2.php",
	),
	array(
		"CONDITION"	=>	"#^/house-projects/([-a-z0-9]+)/gallery+#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/house-projects1/gallery.php",
	),
	array(
		"CONDITION"	=>	"#^/house-projects/([-a-z0-9]+)/sales+#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/house-projects1/sales.php",
	),
	array(
		"CONDITION"	=>	"#^/house-projects/([^\\?]*)([\\s\\S]*)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/house-projects1/detail.php",
	),
	array(
		"CONDITION"	=>	"#^/zhilye-kompleksy/([-a-z0-9]+)/gallery+/*[\s\S]*#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/livecomplex/gallery.php",
	),
	array(
		"CONDITION"	=>	"#^/townhouses/([-a-z0-9]+)/gallery+/*[\s\S]*#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/townhouses1/gallery.php",
	),
	array(
		"CONDITION"	=>	"#^/house-projects/([-a-z0-9]+)/map+#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/house-projects1/map.php",
	),
	array(
		"CONDITION"	=>	"#^/zhilye-kompleksy/([-a-z0-9]+)/credit+#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/livecomplex/credit.php",
	),
	array(
		"CONDITION"	=>	"#^/townhouses/([-a-z0-9]+)/credit+#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/townhouses1/credit.php",
	),
	array(
		"CONDITION"	=>	"#^/zhilye-kompleksy/([-a-z0-9]+)/sales+#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/livecomplex/sales.php",
	),
	array(
		"CONDITION"	=>	"#^/townhouses/([-a-z0-9]+)/sales+#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/townhouses1/sales.php",
	),
	array(
		"CONDITION"	=>	"#^/projects/([-a-z0-9]+)/gallery+#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/projects1/gallery.php",
	),
	array(
		"CONDITION"	=>	"#^/zhilye-kompleksy/([^\\?]*)([\\s\\S]*)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/livecomplex/detail.php",
	),
	array(
		"CONDITION"	=>	"#^/townhouses/([^\\?]*)([\\s\\S]*)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/townhouses1/detail.php",
	),	
	array(
		"CONDITION"	=>	"#^/zhilye-kompleksy/([-a-z0-9]+)/map+#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/livecomplex/map.php",
	),
	array(
		"CONDITION"	=>	"#^/townhouses/([-a-z0-9]+)/map+#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/townhouses1/map.php",
	),
	array(
		"CONDITION"	=>	"#^/projects/([-a-z0-9]+)/sales+#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/projects1/sales.php",
	),
	array(
		"CONDITION"	=>	"#^/house-projects/([-a-z0-9]+)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/house-projects1/detail.php",
	),
	array(
		"CONDITION"	=>	"#^/projects/([^\\?]*)([\\s\\S]*)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/projects1/detail.php",
	),
	array(
		"CONDITION"	=>	"#^/projects/([-a-z0-9]+)/map+#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/projects1/map.php",
	),	
	array(
		"CONDITION"	=>	"#^/zhilye-kompleksy/([-a-z0-9]+)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/livecomplex/detail.php",
	),
	array(
		"CONDITION"	=>	"#^/townhouses/([-a-z0-9]+)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/townhouses1/detail.php",
	),

	array(
		"CONDITION"	=>	"#^/press/(\\w+)/([0-9]+)#",
		"RULE"	=>	"SECTION=$1&ID=$2",
		"ID"	=>	"",
		"PATH"	=>	"/press1/index.php",
	),
	array(
		"CONDITION"	=>	"#^/about/testimonial#",
		"PATH"	=>	"/about1/a_replies.php",
	),
	array(
		"CONDITION"	=>	"#^/about/partners#",
		"PATH"	=>	"/about1/a_partners.php",
	),
	array(
		"CONDITION"	=>	"#^/career/vacancy#",
		"PATH"	=>	"/career1/vacancy.php",
	),
	array(
		"CONDITION"	=>	"#^/house-projects#",
		"PATH"	=>	"/house-projects1/index.php",
	),
	array(
		"CONDITION"	=>	"#^/about/archieve#",
		"PATH"	=>	"/about1/a_archieve.php",
	),
	array(
		"CONDITION"	=>	"#^/kaskad-service#",
		"PATH"	=>	"/newpages/otdelka.php",
	),
	array(
		"CONDITION"	=>	"#^/about/archive#",
		"PATH"	=>	"/about1/a_achieve.php",
	),
	array(
		"CONDITION"	=>	"#^/about/company#",
		"PATH"	=>	"/about1/a_company.php",
	),
	array(
		"CONDITION"	=>	"#^/about/leaders#",
		"PATH"	=>	"/about1/a_leaders.php",
	),
	array(
		"CONDITION"	=>	"#^/news/([0-9]+)#",
		"RULE"	=>	"ID=$1",
		"ID"	=>	"",
		"PATH"	=>	"/news/index.php",
	),
	array(
		"CONDITION"	=>	"#^/about/social#",
		"PATH"	=>	"/about1/a_social.php",
	),
	array(
		"CONDITION"	=>	"#^/about/awards#",
		"PATH"	=>	"/about1/a_awards.php",
	),
	array(
		"CONDITION"	=>	"#^/press/(\\w+)/#",
		"RULE"	=>	"SECTION=$1",
		"ID"	=>	"",
		"PATH"	=>	"/press1/index.php",
	),
	array(
		"CONDITION"	=>	"#^/career/work#",
		"PATH"	=>	"/career1/work.php",
	),
	array(
		"CONDITION"	=>	"#^/press/(\\w+)#",
		"RULE"	=>	"SECTION=$1",
		"ID"	=>	"",
		"PATH"	=>	"/press1/index.php",
	),
	array(
		"CONDITION"	=>	"#^/zhilye-kompleksy#",
		"PATH"	=>	"/livecomplex/index.php",
	),
	array(
		"CONDITION"	=>	"#^/townhouses#",
		"PATH"	=>	"/townhouses1/index.php",
	),
	array(
		"CONDITION"	=>	"#^/contacts#",
		"PATH"	=>	"/contacts1/index.php",
	),
	array(
		"CONDITION"	=>	"#^/projects#",
		"PATH"	=>	"/projects1/index.php",
	),
	array(
		"CONDITION"	=>	"#^/career#",
		"PATH"	=>	"/career1/index.php",
	),
	array(
		"CONDITION"	=>	"#^/press#",
		"PATH"	=>	"/press1/index.php",
	),
	array(
		"CONDITION"	=>	"#^/about#",
		"PATH"	=>	"/about1/index.php",
	),
	array(
		"CONDITION"	=>	"#^/([^?]*)([\\s\\S]*)#",
		"RULE"	=>	"CODE=$1",
		"ID"	=>	"",
		"PATH"	=>	"/pages1/index.php",
	),
);

?>


Спасибо!
  • Вопрос задан
  • 3414 просмотров
Решения вопроса 1
@phper1785
Можно посоветовать использовать комплексные компоненты битрикс
есть CComponentEngine::MakeComponentUrlTemplates и CComponentEngine::ParseComponentPath
поможеть сократить urlwrite.php, слеши в конце лучше убирать.
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 3
ioffeaod
@ioffeaod
Web программист
Решается через .htaccess
Пример.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ www.site.ru [R=301,L]
RewriteCond %{HTTP_HOST} ^site\.ru
RewriteRule ^(.*)$ www.site.ru/$1 [R=permanent,L]
Ответ написан
Комментировать
kompi
@kompi
nullstack devoops
Condition - это же обычная регулярка: /? или /{0,1}
Ответ написан
Комментировать
babarun
@babarun Куратор тега 1С-Битрикс
Безумный план моих идей в руках больных людей
В самое начало массива добавьте

array(
		"CONDITION" => "#^/project/(.)*\$#",
		"RULE" => "CODE=\$1",
		"ID" => "",
		"PATH" => "/projects1/index.php",
	),


А то что с адреса "/project/..." идёт подключение скрипта в "/project1/..." - это так и задумано?
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы