A
A
AgeWalker2020-07-02 16:16:26
htaccess
AgeWalker, 2020-07-02 16:16:26

How to specify the condition for selecting only subpages in the htacces file in RewriteCond?

There are pages starting with /auxpage_
Example: /auxpage_kontakty/ and /auxpage_kak-zakazat/
Question: how to write a condition in .htacces, that is, RewriteCond, so that all subpages of such pages would be selected.
Where it all goes: all subpages of pages that start with auxpage_ should give 404.

I tried many options, but none came up.
Here are code examples:

#RewriteCond %{REQUEST_URI} ^/auxpage_(.*)/(.*)
#RewriteCond %{REQUEST_URI} !^/auxpage_(.*)/$
##-- RewriteCond %{REQUEST_URI} ^/auxpage_.*/(.*)
##-- RewriteCond %{REQUEST_URI} !^/auxpage_.*/$
#-- RewriteCond %{REQUEST_URI} ^/[auxpage]*/(.*)
#-- RewriteCond^([^/]*)/$
#-- RewriteCond %{REQUEST_URI} ^/auxpage_[a-Z0-9]/(.*)
#-- RewriteCond %{REQUEST_URI} !^/auxpage_(.*)/$
#RewriteRule ^(.*)$ [R=404]


I'll add an explanation.
/auxpage_kak-zakazat/ <- This page should normally open
/auxpage_kak-zakazat/234/ <- This page should return a 404 error

Thank you in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2020-07-02
@AgeWalker

RewriteCond %{REQUEST_URI}  ^/auxpage_.+/.+$
RewriteRule ^ - [R=404,L]

Or without RewriteCond
RewriteRule ^auxpage_.+/.+ - [R=404,L]

V
Viktor Taran, 2020-07-02
@shambler81

RewriteCond %{REQUEST_URI} ^auxpage_.+/.+$
Alternatively, you can also do denial
RewriteCond %{REQUEST_URI} !^^auxpage_.+\/$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question