很简单,只需在站点的文档根目录中的.htaccess文件中添加以下内容即可(效率不高,因为 Apache 会在每次请求时读取和解析文件,还假设目录Includes已被允许在httpd.conf为您的站点文档根目录),或者最好在Apache 的httpd.conf中的Virtualhost定义中,或相关的包含.conf:
RewriteEngine On
RewriteCond %{HTTP_HOST) ^peku33\.net$ [NC]
RewriteRule ^/?SomeOTHERText/ SomeSite.php [L]
RewriteCond %{HTTP_HOST) ^mysite [NC]
RewriteRule ^/?SomethingElse/ SomeOtherSite.php [L]
RewriteCond %{HTTP_HOST) ^mysubdomaint [NC]
RewriteRule ^/?Blablabla/Blabla/ SomeotherSiteEtc.php [L]
#Attempt to block direct requests to a .php script, only internally rewritten requests should get through
RewriteCond %{THE_REQUEST} SomeSite\.php [NC]
RewriteRule ^/?SomeSite.php - [F,NC]
笔记:
F = Fail (Could use G=Gone or R=### instead)
NC = Not Case-sensitive
L = Last
^/? = optional leading slash, best to leave in place, as the leading slash is stripped from the URI, when the rule is .htaccess based.
如果您不清楚上述规则的作用,或者如果您想要更抽象的东西,请考虑以下Apache mod_rewrite文档。