简体   繁体   中英

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! I also have index.php in my form that has POST method!

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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