A
A
AlexMark2017-03-19 18:30:40
htaccess
AlexMark, 2017-03-19 18:30:40

When to use RewriteCond?

I have changed the symbolic category code. I want to make 301 ed. I wrote the following condition RewriteRule ^(.*)/old-category/(.*)$ $1/new-category/$2 [R=301,L]. But I see in many examples there is also RewriteCond before the rule. Should I use it in this case? I just don't quite understand when to use this condition.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2017-03-21
@shambler81

Cond is "IF" for more precise regular expressions.
For example
If this is not a file
AND if this is not such a link
and if it is a get parameter such and such
THEN
Rule
You can also pass part of the conditions from the conda to the root
For example $1 from the root is %1
Where without it there is no way
For example to make a redirect with get parameters, get is not part of the url.
And it can be written in the condition.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question