繁体   English   中英

.htaccess和DirectoryIndex

[英].htaccess and DirectoryIndex

我的根文件夹中有两个文件: main.htmlindex.php 好吧,通常index.php具有较高的响应优先级,只是想更改逻辑,所以首先用户必须访问main.html ,然后将其重定向到index.php 我在.htaccess尝试了以下代码,但未按预期工作。 实际上,执行完此操作后,现在第一页已正确更改为main.html ,但从未将其重定向到index.php! 实际上,它一次又一次地返回main.html (就像循环!)。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

DirectoryIndex main.html /main.html

ps:

1-即使我尝试请求index.php,它也会打开main.html!

您可以在htaccess文件中使用以下命令更改目录的默认页面,就像在问题中所做的一样。 导航到“ www.coolsite.com/”时,用户将登陆main.html(而不是index.php)。

//Change default directory page
DirectoryIndex main.html

要将用户重定向到另一个页面,可以使用以下命令:

window.location = "http://www.coolsite.com/index.php";

好吧,似乎WordPress和静态内容[索引页面!]并没有出现! (主要是由于现有的RewriteRule [s] + WP内部)

解决方法是创建一个“页面模板”(您希望显示为索引页面的静态内容),并要求WP将其显示为Front-page。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM