.htaccess file:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Options -Indexes
I want to remove index.php
from URL and also when someone enters test.xyz.com
in the address bar it should redirect to https://test.xyz.com
.
I tried some codes as below by commenting the above code and then the problem was that when I enter test.xyz.com
it's automatically redirecting to https://test.xyz.com
but when I go to some other link like https://test.xyz.com/user/list
its showing error.
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
So I need a better .htaccess file which will remove index.php
as well as redirect to https
for all URLs in my subdomain.
NOTE: Need combined version of both the above
.htaccess
code.
You may use this code in your site root .htaccess:
DirectoryIndex index.php
Options -Indexes
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,NE,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [L]
Test it after clearing your browser cache or test in a new browser.