w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
.htaccess: RewriteRules working for /*.php are not working for /index.php

You can use:

Options +FollowSymLinks
RewriteEngine on

# No trailing slashes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} !^.localhost$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L,NE]

RewriteBase /
RewriteRule contact$        contact.php?lang=en [L,QSA]     # default
language
RewriteRule contact/([^/]+)/?$   contact.php?lang=$1 [L,QSA]    # any other
language

# default language (don't show any thing in the URL)
RewriteRule index/en$       / [L,R=301]

# requesting /index.php, one should be forwarded to /
RewriteCond %{THE_REQUEST} /index.php [NC]
RewriteRule ^(.*?)index.php$ /$1 [L,R=301,NC,NE]

RewriteRule ^/?$             index.php?lang=en [L,QSA]       # default
language
RewriteRule ^index/([^/]+)/?$     /index.php?lang=$1 [L,QSA]      # any
other language




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.