Переписать .htaccess за исключением некоторых request_uri

У меня есть файл .htaccess, но он не работает должным образом.

Redirect /some/dir http://www.example.com/someother/dir/29

<IfModule mod_rewrite.c>
RewriteEngine on

# HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !=/buy/confirm
RewriteCond %{REQUEST_URI} !=/index.php
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_URI} !=/some/dir
RewriteRule ^(.*)$ index.php?issue=$1 [L,QSA]
</IfModule>

Я проверял это с http://htaccess.mwl.be/ и я не понимаю строку, когда я вхожу «http://www.example.com/buy/confirm«:

RewriteCond %{REQUEST_URI} !=/buy/confirm   This condition was met.

Что именно содержит% {REQUEST_URI} для выполнения условия! = / Купить / подтвердить ?? Я пробовал и / купить / подтвердить и купить / подтвердить и ничего.

Я не хочу перенаправлять на HTTPS, если URL-адрес купить / подтвердить.

Спасибо!

0

Решение

Попробуй это:

RewriteEngine On

#redirect everything except /buy/confirm to https
RewriteCond %{HTTPS} =off
RewriteCond %{REQUEST_URI} !^\/buy\/confirm\/
RewriteRule (.*) https://%{HTTP_HOST}/$1 [L,R=301]

#redirect /buy/confirm to http if it is accesed by https
RewriteCond %{HTTPS} =on
RewriteCond %{REQUEST_URI} \/buy\/confirm\/
RewriteRule (.*) http://%{HTTP_HOST}/$1 [L,R=301]
0

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

Ты можешь использовать:

Redirect /some/dir http://www.example.com/someother/dir/29

<IfModule mod_rewrite.c>
RewriteEngine on

# HTTPS
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/buy/confirm
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !/favicon.ico
RewriteCond %{REQUEST_URI} !^/some/dir
RewriteRule ^(.*)$ index.php?issue=$1 [L,QSA]
</IfModule>
0

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