Я бы хотел, чтобы корень (www.example.com) был перенаправлен на index.html, но если index.html не существует, его нужно перенаправить на index.php.
Также, если URL выглядит (www.example.com/anything-here) для перенаправления на index.php.
DirectoryIndex index.php index.html index.htm index.cgi
<IfModule mod_rewrite.c>
RewriteEngine On
## I would like the root ( www.example.com ) to be redirected to the index.html only if it has nothing behide it example : www.example.com/page-login.html or www.example.com/index.php
## I tried the code below but it is not working
RewriteRule ^/?$ index.html [L]
## The code below just rewrites for example : page-login.html to the index.php ( this code works for me )
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.css|\.js|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) %{ENV:REWRITEBASE}index.php
</IfModule>
Части в приведенном выше коде работают, но другие части не работают.
Любая помощь будет великолепна.
ОБНОВЛЕНИЕ ОБНОВЛЕНО
Я решил это рабочим кодом ниже:
DirectoryIndex index.html index.htm index.php index.cgi
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) %{ENV:REWRITEBASE}index.php [L]
</IfModule>
Комментарий ниже поставил меня на правильный путь; -)
Спасибо, Майкл Берковски