我正在尝试在我的.htaccess文件中将index.php
的优先级设置为index.html
(但仅用于登录页),该文件运行良好
但对于?page_id=16
,它也显示相同的index.html页面,我不想要
RewriteEngine On
RewriteBase /
RewriteRule ^index'.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
DirectoryIndex index.html index.php
RewriteRule . /index.php [L]
注意:我使用的是wordpress。
试试这个代码:
RewriteEngine On
RewriteRule ^$ /index.html [L,R=301]
如果您通过DirectoryIndex定义服务器应该交付index.html
(如果存在),并且您访问url /?page_id=16
,则会交付带有该参数的index.html
。这个参数什么也不做——它是静态HTML。
不能同时使用index.html
和index.php
作为/
的DirectoryIndex并期望其工作。
向index.php
添加代码,如果未给定参数,则返回index.html
的内容。CCD_ 12可能就足够了。仅使用index.php
作为DirectoryIndex。