简体   繁体   中英

priority to index.html for index.php in .htaccess

i am trying to set the priority of index.php to index.html (but just for landing page) in my .htaccess file that works fine

but for ?page_id=16 its also display the same index.html page that i don't want

RewriteEngine On
RewriteBase /

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

DirectoryIndex index.html index.php

RewriteRule . /index.php [L]

NOTE: i am using wordpress.

If you define via DirectoryIndex that the server should deliver index.html if it is there, and you access the url /?page_id=16 , then index.html with that parameter is delivered. And the parameter does nothing - it's static HTML.

You cannot use BOTH index.html and index.php as DirectoryIndex for / and expect it to work.

Add code to index.php that returns the content of index.html if no parameter is given. readfile('index.html'); exit(); might be enough. Only use index.php as DirectoryIndex.

Try this code :

RewriteEngine On
RewriteRule ^$ /index.html [L,R=301]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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