R
R
rinaz222020-02-12 20:37:42
htaccess
rinaz22, 2020-02-12 20:37:42

How to issue 404 if you go to the pages directory, and if not on the page?

Hello! There is a /pages/ directory, the files that are in this directory are opened not as pages/page.php, but as /page . But if you go to /pages/page.php, then the file will open anyway, so that this would not be in htaccess, I added the following:
RedirectMatch 404 ^/pages/.*
But another problem arose.
I want that when there was such an address /ad_pages, then all requests were sent to the pages/index.php file.
To do this, I wanted to write like this:
RewriteRule ^ad_pages$ pages/index.php [L]
But it interferes RedirectMatch 404 ^/pages/.*
How to make them not interfere with each other?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2020-02-12
@rinaz22

/pages/.htaccess

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^ - [R=404,L]

/.htaccess
RewriteEngine On

RewriteRule ^ad_pages$ pages/index.php [L]

N
Nikita Shinkevich, 2020-02-12
@domres

I have such a cranberry: Redirect 301 /pages/ /404/
But it shows any docks inside the directory ... maybe I just didn’t understand the question ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question