I have this code
RewriteCond %{THE_REQUEST} /index\.html? [NC]
RewriteRule ^(.*/)?index\.html?$ /$1 [R=301,L]
Where is to place this code on my index.html sites?.I have my
"www.text.com/index.html"
and i need to redirect to
"www.text.com"
You need to create a .htaccess
(plain text) file in the same folder as your index.html
Note that there is no first part, just dot-htaccess.
The code in your question is typical htaccess script.
Note that htaccess files only work for Apache webservers, which are the ones typically used on shared hosting systems like GoDaddy, HostGator, etc - and also on XAMPP, WAMP, MAMP, LAMP
In my first answer I did not check your htaccess code. I notice that this line was missing from top of the code:
RewriteEngine On
So, it would look like:
RewriteEngine On
RewriteCond %{THE_REQUEST} /index\.html? [NC]
RewriteRule ^(.*/)?index\.html?$ /$1 [R=301,L]
If that doesn't work, try one of these:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
or
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC]
RewriteRule ^ %1 [R=301,L]
Sources: