.htaccess — перенаправление бесконечного цикла, отлично работает локально

Я надеялся, что вы мне чем-нибудь поможете. У меня есть следующий htaccess в корне моего сайта. Идея заключается в том, что когда вы вводите [mywebsite] / [country_code], вы перенаправляетесь на [mywebsite] /teaser.php?country= [country_code] Когда я тестирую его локально на моем apache, он работает отлично; но когда я загружаю его на свой веб-сервер, он входит в бесконечный цикл [mywebsite] / [country_code] / [country_code] / [country_code] / etc …
Можете ли вы сказать мне, что я делаю здесь не так?

RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^cl\/*$ teaser.php?country=cl
RewriteRule ^ar\/*$ teaser.php?country=ar
RewriteRule ^br\/*$ teaser.php?country=br
RewriteRule ^bo\/*$ teaser.php?country=bo
RewriteRule ^co\/*$ teaser.php?country=co
RewriteRule ^cl\/*$ teaser.php?country=cl
RewriteRule ^la-ec\/*$ teaser.php?country=la-ec
RewriteRule ^py\/*$ teaser.php?country=py
RewriteRule ^pe\/*$ teaser.php?country=pe
RewriteRule ^ve\/*$ teaser.php?country=ve
RewriteRule ^cr\/*$ teaser.php?country=cr
RewriteRule ^cu\/*$ teaser.php?country=cu
RewriteRule ^mx\/*$ teaser.php?country=mx
RewriteRule ^ni\/*$ teaser.php?country=ni
RewriteRule ^pa\/*$ teaser.php?country=pa
RewriteRule ^sv\/*$ teaser.php?country=sv
RewriteRule ^gt\/*$ teaser.php?country=gt
RewriteRule ^ht\/*$ teaser.php?country=ht
RewriteRule ^hn\/*$ teaser.php?country=hn
RewriteRule ^do\/*$ teaser.php?country=do
RewriteRule ^uy\/*$ teaser.php?country=uy

Спасибо!

0

Решение

У тебя не так много правил. Просто используйте простое регулярное выражение, чтобы объединить все правила в одно правило и провести повторное тестирование:

RewriteEngine on

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([a-z]{2}(?:-[a-z]{2})?)/?$ teaser.php?country=$1 [L,QSA,NC]
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector