我有一个很好的htaccess。我想再做一件事。我有在网站的网址严格控制它的工作很好。我想阻止人们向网站添加任意请求。
我使用友好的网址。我的URL的工作方式如下:

http://www.mysite.net/pagename

因此,如果您试图放入一个不存在的页面,您会得到一个404错误。一切正常。但我想进一步限制。
目前,如果您放入index.php,它也可以工作,并且您将被带到
http://www.mysite.net/index.php

我想限制这种行为,因为人们可以添加和搜索引擎可以索引添加任意请求到url,如
http://www.mysite.net/index.php?test=somthing

这不会抛出404,而是转到主页index.php。我希望这些类型的url抛出404。
下面是我的htaccess,我可以做些什么来修复它。
RewriteEngine On


#RewriteRule ^gallery(/((([a-zA-Z0-9-]+)(/(\d+))?)/?)?)?$ index.php?page=77&groupId=$4&showpage=$6 [NC,QSA,L]

RewriteRule ^gallery/([a-zA-Z0-9-]+)/(\d+)/?$ index.php?page=77&groupId=$1&showpage=$2 [NC,QSA,L]
RewriteRule ^gallery/([a-zA-Z0-9-]+)/?$ index.php?page=77&groupId=$1 [NC,QSA,L]
RewriteRule ^gallery/?$ index.php?page=77 [NC,QSA,L]

RewriteRule ^video/(\d+)/([a-zA-Z0-9-]+)/?$ index.php?page=60&showpage=$1&v=$2 [NC,QSA,L]
RewriteRule ^video/(\d+)/?$ index.php?page=60&showpage=$1 [NC,QSA,L]
RewriteRule ^video/?$ index.php?page=60 [NC,QSA,L]

RewriteCond %{REQUEST_FILENAME} !-f [NC]
#RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [NC,QSA,L]

最佳答案

嗨,试试这个链接:http://bobpeers.com/technical/404_redirectionhttp://www.totallyphp.co.uk/custom-error-pages-using-htaccess

关于php - 需要进行htaccess调整,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7847579/

10-09 06:21
查看更多