在我的根网络目录下,我有两个文件:
关于我们.php
关于我们.php
现在转到此 URL http://local.com/about-us.php 将呈现关于我们的文件.php。如果我要做相反的事情,我怎么能规定.htaccess,只要上面的URL被访问,就会呈现aboutus.php?
如果您有权访问整个服务器配置,最有效的方法是使用 mod_alias
。不幸的是,这需要在VirtualHost
配置中完成 - 只有当您获得对该服务器的root访问权限时才能访问该配置。
Alias /about-us.php /full/local/path/to/aboutus.php
如果您无法编辑 VirtualHost 配置,请使用 mod_rewrite
(但需要更多的服务器资源,因为每个请求都必须与这些规则匹配):
RewriteEngine On
RewriteRule ^about-us.php aboutus.php [L]
应该做这个伎俩。