Tec*_*lco 11 apache .htaccess mod-rewrite redirect directoryindex
我有一个域和一个子域(用于移动和客户端)的共享主机.每个域和子域都有不同的默认索引页.托管公司告诉我将所有内容放在我的.htaccess文件中,因为我无法访问httpd.conf.
我想要做的是:
DirectoryIndex应该是:index.htmlDirectoryIndex应该是:mobile-index.htmlDirectoryIndex应该是:post.phpDirectoryIndex应该是:vote.php编辑:另外,如果我去domain1.com/page/,DirectoryIndex应该是:index.html.如果我去mobile.domain1.com/page/,DirectoryIndex应该是:mobile-index.html
我可以在.htaccess文件中添加什么来更改DirectoryIndex每个子域?
非常感谢你
Boo*_*eus 18
<IfDefine>不是这样的.<IfDefine>仅在apache启动时运行.你应该使用mod_rewrite解决方案.查看@tzakrajs的答案.
您可以在.htaccess文件中使用它:
SetEnvIf Host ^www\. page=www
SetEnvIf Host ^mobile\. page=mobile
rewriterule ^.*$ test.php?subdomain=%{ENV:page} [QSA,L]
Run Code Online (Sandbox Code Playgroud)
只需使用配置所有子域SetEnvIf,然后让PHP发挥其魔力.
| 归档时间: |
|
| 查看次数: |
3440 次 |
| 最近记录: |