I am not able to remove index.php from URL with the htaccess code given below. Could anyone please help with this. Thanks. #######################################
# 1. Remove index.php
# 2. Redirect all example.com to www.example.com/
# 3. Enforce trailing SLASH on HTTP
# 4. Enforce trailing SLASH on HTTPS and force to www.example.com/secure/
# 5. Enfore HTTP for non /secure/ folder and redirect to www.example.com
# 6. Enfore HTTPS for /secure/ folder and redirect to www.example.com/secure/
#######################################
Options -Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
#--------------------------------------
# 1. Remove index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [NC]
#tried the following also
#RewriteRule ^(.*)$ /index.php/$1 [NC]
#-------------------------------------- #--------------------------------------
# 2. Redirect all example.com to www.example.com
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule ^(.*)$ http://www.example.com/ [NC]
#--------------------------------------
#--------------------------------------
# 3. Enforce trailing SLASH on HTTP
RewriteCond %{HTTPS} off
#if you want to exclude index.php files, otherwise comment the following line
#RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !\.[^./]+$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://www.example.com/ [NC]
#--------------------------------------
#--------------------------------------
# 4. Enforce trailing SLASH on HTTPS
RewriteCond %{HTTPS} on
#The RewriteCond %{HTTPS} on portion may not work for all web servers.
##RewriteCond %{HTTP:X-Forwarded-SSL} on
#if you want to exclude index.php files, otherwise comment the following line
#RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !\.[^./]+$
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteCond %{REQUEST_URI} !/secure/favicon\.ico$
RewriteRule ^(.*)$ [
example.com...] [NC]
#--------------------------------------
#--------------------------------------
# 5. Enfore HTTP for non /secure/ folder and redirect to www.example.com
RewriteCond %{HTTPS} on
#The RewriteCond %{HTTPS} on portion may not work for all web servers.
##RewriteCond %{HTTP:X-Forwarded-SSL} on
RewriteCond %{REQUEST_URI} !^/secure/?.*$
RewriteRule ^(.*)$ http://www.example.com/ [NC]
#--------------------------------------
#--------------------------------------
# 6. redirect all http traffic to https, if it is pointed at /secure
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/secure/?.*$
RewriteCond %{REQUEST_URI} !/secure/favicon\.ico$
RewriteRule ^(.*)$ [
example.com...] [NC]
#--------------------------------------