.htaccess 需要htaccess帮助设置重写库吗
我有一个本地主机环境和一个测试服务器环境。我在本地编写所有代码,有时将更改推送到测试服务器。我的代码需要足够智能,知道它在哪里运行,这样它就可以调用适当的url(本地或测试) 我的本地环境URL为“my.local”,测试环境URL为“test.somedomain.com” 我需要能够设置baserewrite或根据代码所在的url进行自我调整的内容.htaccess 需要htaccess帮助设置重写库吗,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,我有一个本地主机环境和一个测试服务器环境。我在本地编写所有代码,有时将更改推送到测试服务器。我的代码需要足够智能,知道它在哪里运行,这样它就可以调用适当的url(本地或测试) 我的本地环境URL为“my.local”,测试环境URL为“test.somedomain.com” 我需要能够设置baserewrite或根据代码所在的url进行自我调整的内容 有什么帮助吗?如果您已经设置了virtualhost&DocumentRoot 您只需为documentroot执行以下操作: RewriteB
有什么帮助吗?如果您已经设置了
virtualhost
&DocumentRoot
您只需为documentroot执行以下操作:
RewriteBase /
在每个目录.htaccess
中,位于文档根目录中
对于其他文件夹,您必须设置一个(上下文:服务器配置,虚拟主机),一个mod_alias
指令
例如:
别名/xyz/abc/def
并在每个目录中使用指令.htaccess
示例来源::
# /abc/def/.htaccess -- per-dir config file for directory /abc/def
# Remember: /abc/def is the physical path of /xyz, i.e., the server
# has a 'Alias /xyz /abc/def' directive e.g.
#
RewriteEngine On
# let the server know that we were reached via /xyz and not
# via the physical path prefix /abc/def
RewriteBase /xyz
# now the rewriting rules
RewriteRule ^oldstuff\.html$ newstuff.html
使用.htaccess文件检查此页面是否重定向示例: