A
A
arty_sh2016-06-28 13:02:43
Apache HTTP Server
arty_sh, 2016-06-28 13:02:43

How to set exclusions in .htaccess?

Given:
1) Website - domen.ru
2) domen.ru/ products /name_category/ - leads to the products.php file and the store category is processed
3) RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond % {REQUEST_URI} !\..{1,10}$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^products/(.+[^/])/(.+[^/])/?$ products .php?category[]=$1&category[]=$2 [L,NC,QSA]
RewriteRule ^products/(.+[^/])/?$ products.php?category[]=$1 [L,NC,QSA ]
Goal:
1) Remove products from url
I wanted to make a link like domen.ru/category/ immediately lead to the processing file. And make other pages the usual exceptions, for example, domen.ru/contacts/ (to lead to contacts.php).
I wrote this rule:
RewriteRule ^(.+[^/])/?$ products.php?category[]=$1 [L,NC,QSA]
And for exceptions:
RewriteRule ^contacts/?$ contacts.php [L,NC ]
But now all pages follow this rule: RewriteRule ^(.+[^/])/?$ products.php?category[]=$1 [L,NC,QSA]
Swapped rows, but doesn't help. Tell me what can be done. Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2016-06-28
@shambler81

Everything is simple
here 1. Add an exception you already know how to do it! in RewriteCond
so add another cond

конд
конд
конд
конд
что делать

Now about cutting off,
as I understand it, you know a little about regular expressions, so you understand what $1$2 is, and so on - if not, everything is in brackets, which brackets in turn that and bucks.
But it will work on the steering wheel, and you need the conditions in the cond SO
Bucks from the cond looks like this %1 %2
In that case.
RewriteCond %{REQUEST_URI}  (скобка первая) ляляля ( скобка вторая)
RewriteRule .* %1%2

Accordingly, you will receive a redirect to what is in brackets, bypassing the lala. But that's not all
. You have an error in the redirect to get it stupidly does not work
escape everything? in - where
otherwise they simply will not appear.
If not enough, here are a couple of examples
klondike-studio.ru/blog/snipet-for-htaccess

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question