V
V
Vadim9972014-10-03 15:22:42
PHP
Vadim997, 2014-10-03 15:22:42

How do I get a 404 error when changing a post?

I made a CNC by writing the following code in htaccess:

AddDefaultCharset utf-8
 
 <IfModule mod_charset.c>

    CharsetDisable On
     
    CharsetSourceEnc utf-8

    CharsetDefault utf-8
</IfModule>

Options +FollowSymLinks

<IfModule mod_rewrite.c>
 
    RewriteEngine On
 
    RewriteBase /
 
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ mysite/index.php?post=$1 [L,QSA]
  
</IfModule>

I can’t make it so that when changing a post in the address bar, for example, to dsdfwefds, an error 404 appears. That is, there should not be such a post. An example would be Habr or another site. Changing the post to the left post in the address bar on Habré, a 404 error immediately appears.
Thank you, Vadim1997

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-10-03
@ekifox

I can’t judge exactly, but with CNC, it’s better to do the handler in php.
if($_GET['post'] != 'blahblahblah') header('location: /404');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question