G
G
Grigory Vasilkov2015-11-26 23:47:30
Apache HTTP Server
Grigory Vasilkov, 2015-11-26 23:47:30

How to set up a redirect in .htaccess from index.(php|html) to root?

DirectoryIndex index.html index.php

# -- INIT
RewriteEngine on
RewriteBase /

# -- PRODUCTION
# RewriteCond %{HTTP_HOST} ^www.assist\.loc$ [NC]
# RewriteRule ^(.*)$ http://assist.loc/$1 [R=301,L]

# -- SEO index.html // index.php ??????????? DONT KNOW ????????
RewriteCond %{THE_REQUEST} ^.*/index\.(php|html)
RewriteRule .* / [R=301,L]

# -- HACKING
RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
RewriteRule .* /index.php [F]

# -- DIRECTORIES
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.+)/$
RewriteRule ^(.+)/$  /$1 [R=301,L]

# -- FILES
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L]

Please help me figure out how to correctly make a 301 redirect from the /index.php page and the /index.html page to /.
** Now I can either completely redirect from any address to "/".
** Or again it turned out "/index.php" - a cyclic redirect.
** I tried to make a redirect directly from the code, but if the address is like this, but the framework cuts the file from the query string if it matches an existing file

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question