A
A
Antonio Vivaldi2019-02-07 13:06:33
htaccess
Antonio Vivaldi, 2019-02-07 13:06:33

Do I need a redirect from /index.php to /index? How to implement?

Changed links in .htacces from /index.php to /index Do I need to redirect to avoid clones in indexing? If yes, how?

AddDefaultCharset utf-8
Options +FollowSymLinks

RewriteEngine On
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valentin, 2019-02-07
@devaloevera

It is better to glue index.php to the root of the site

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ https://site.com/ [R=301,L]

S
ShamblerR, 2019-02-07
@ShamblerR

RewriteCond %{REQUEST_URI} ^(.*)/index\.php$
# URL contains index.php at the end.
RewriteCond %{REQUEST_METHOD} =GET
# Detect GET request in URL (not POST).
RewriteRule ^(.*)$ %1/ [R=301,L]
# Remove index.php from URL.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question