htaccess重写规则忽略index.html
我正在使用 CodeIgniter 和 .htaccess
重写 URL,但我希望它忽略 index.html
。
这样我们就可以随时上传 index.html
,因为这将是一个临时登陆页面。通过 index.php
上的主站点链接。
这是当前 .htaccess
中的内容,我已将服务器的目录索引设置为 index.html index.php
RewriteEngine on
RewriteCond $1 !^(index\.html|index\.php|js|img|fonts|data|css|uploaded|mobile_devices|audioplayer|emails|robots\.txt|archive_blog)
RewriteRule ^(.*)$ /index.php/$1 [L]
感谢您的帮助
I'm using CodeIgniter and .htaccess
to rewrite the URLs but I want it to ignore index.html
.
This is so we can upload an index.html
at any time as this will be a temporary landing page. With a link through to the main site on the index.php
.
This is what is currently in .htaccess
and I have set the server's directory index to index.html index.php
RewriteEngine on
RewriteCond $1 !^(index\.html|index\.php|js|img|fonts|data|css|uploaded|mobile_devices|audioplayer|emails|robots\.txt|archive_blog)
RewriteRule ^(.*)$ /index.php/$1 [L]
Thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
看起来您想重写目录中不存在的所有内容。
尝试这个而不是当前的 RewriteCond:
that rather looks like you want to rewrite everything that does not really exist in your directory.
try this instead of your current RewriteCond:
您可以通过使用 FilesMatch 指令直接限制对它的访问,而不是使用 RewriteCond 忽略 index.html 文件。 FilesMatch 接受可以根据文件名(例如,index.html)或任何正则表达式进行过滤的正则表达式。
阻止对index.html 文件的访问
这将完全拒绝对index.html 文件的访问。我承认,我不知道这会对搜索引擎抓取产生负面影响。
要了解有关 FilesMatch 指令的更多信息,请参阅 http://httpd.apache.org /docs/current/mod/core.html#filesmatch
至于您当前拥有的列表中的其余目录,您可以锁定所有目录访问,无论名称如何。它会给你更多的未来报道。
要了解有关选项指令的更多信息,请参阅 http://httpd.apache.org /docs/current/mod/core.html#options
最后,您的新 .htaccess 文件将如下所示:
Instead of using RewriteCond to ignore the index.html file, you could instead restrict access to it directly through using the FilesMatch directive. FilesMatch accepts a regular expression which could filter based on file name (e.g., index.html) or any regular expression.
Blocking access to the index.html file
That would completely deny access to the index.html file. I will admit, that I do not know the negative effects this would have on search engine crawling.
To read more about the FilesMatch Directive see http://httpd.apache.org/docs/current/mod/core.html#filesmatch
As for the rest of the directories in that list you currently have, you could just lock down all directory access regardless of name. It would give you a little more coverage going forward.
To read more about the Options Directive see http://httpd.apache.org/docs/current/mod/core.html#options
In the end your new .htaccess file would look something like this:
为什么不使用内置的 environment 函数?
您可以创建一个“维护”环境并将基本控制器设置为您想要的任何内容。然后你只需要编辑index.php 文件来指定你想要的环境。
Why don't you use the built in environment function?
You could create a 'maintenance' environment and set the base controller to whatever you want. Then you would just need to edit the index.php file to specify the environment you want.