Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to redirect index.php to another page properly via .htaccess?

Currently my htaccess file contains this rule, to redirect website.org/index.php to website.org/en/home

RewriteRule index.php /en/home [R=301]

However, currently also other index.php pages in deeper folders redirect! e.g. website.org/folder/index.php redirects to website.org/en/home

How can I have that rule exclusively apply to the root, and no deeper folders? Thanks very much.

like image 271
Sam Avatar asked Mar 05 '11 18:03

Sam


People also ask

What is RewriteEngine on htaccess?

htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.

How do I redirect www to non www htaccess?

E.g.: RewriteCond %{HTTPS} off RewriteCond %{HTTP_HOST} ^www.example.com/$ [NC] RewriteRule ^(. *)$ http://www.example.com [R=301,L] ... @BobbyS I used the solution in this article. It redirects www and HTTP to non-www HTTPS and also handles the trailing / .


1 Answers

RewriteRule ^index.php /en/home [R=301]
like image 186
Zimbabao Avatar answered Sep 22 '22 16:09

Zimbabao