简体   繁体   English

如何防止直接访问PHP页面

[英]How to prevent to direct access of PHP pages

I want to prevent direct access of my PHP pages. 我想防止直接访问我的PHP页面。 I tried running " .htaccess ", but it is not running. 我尝试运行“ .htaccess ”,但未运行。 There are so many pages in my project. 我的项目中有很多页面。 but I want in some of them. 但我想要其中一些。 My PHP pages are: example1.php example2.php 我的PHP页面是:example1.php example2.php

My " .htaccess " code is: 我的“ .htaccess ”代码是:

     Options +FollowSymlinks
     RewriteEngine on
     RewriteRule    ^/?example/([0-9]+)$    exam-ple.php    [NC,L]

If it is OK, then why it is not running. 如果可以,那么为什么它不运行。 I want any type of solution. 我想要任何类型的解决方案。

尝试将这段代码放在PHP页面的最顶部。

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM