简体   繁体   English

防止通过索引访问页面。php

[英]Prevent to access to page by index.php

I use clean URLs in my site and I want to prevent access to my page when a user write index.php in URL!我在我的网站中使用干净的 URL,并且我想阻止用户在 URL 中写入 index.php 时访问我的页面! I also have index.php in my form that has POST method!我的表单中也有index.php具有 POST 方法!

Is there any way I can use something like this:有什么办法可以使用这样的东西:

RewriteCond %{REQUEST_METHOD}  = GET [AND] %{SCRIPT_FILENAME} = index.php
Redirect 301 / http://example.com/

Is this code correct?这段代码正确吗?

EDIT编辑

I use this but it seems it fall in infinity loop !我使用它,但它似乎陷入无限循环!

RewriteCond %{REQUEST_METHOD}  ^GET$ 
RewriteCond %{SCRIPT_FILENAME} ^index.php
Redirect 301 / http://www.XXXXXXXXX.net/

This should work:这应该有效:

RewriteCond %{REQUEST_METHOD}  ^GET$
RewriteCond %{SCRIPT_FILENAME} ^index\.php
RewriteRule ^(.*)$ http://XXXXX.COM/ [R=301]

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

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