htaccess有条件的DirectoryIndex

htaccess有条件的DirectoryIndex

本文介绍了在.htaccess有条件的DirectoryIndex的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使的DirectoryIndex值在的.htaccess 有条件的基于IP的文件,这样 - 例如 - 我的IP看到的的DirectoryIndex 为index.html,然后其他人看到的DirectoryIndex 作为的index.php?

Is it possible to make the DirectoryIndex value in a .htaccess file conditional based on IP, so that - for example - my IP see's DirectoryIndex as index.html and everyone else sees DirectoryIndex as index.php?

有没有其他的解决方案比的mod_rewrite

Is there a solution other than mod_rewrite?

推荐答案

据我所知,没有任何条件的DirectoryIndex的。你可以模拟与一个mod_rewrite的指令,像这样的:

As far as I know, there is no conditional for DirectoryIndex. You could simulate that with a mod_rewrite directive like this one:

RewriteCond %{REMOTE_ADDR} your_ip
RewriteCond -d
RewriteRule (.*)/$ $1/index.html

如果您要排除的网站的其他访问者看到的index.html,然后还用

If you want to exclude other visitors of the site from viewing index.html then also use

RewriteCond %{REMOTE_ADDR} !your_ip
RewriteRule (.*)/index.html$ $1/index.php

这篇关于在.htaccess有条件的DirectoryIndex的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 00:58