开发者

Redirect every index.php to his root folder

开发者 https://www.devze.com 2023-01-31 04:12 出处:网络
I\'d like to know the RewriteRule to redirect(301) every index.php to their root. For example, this url:

I'd like to know the RewriteRule to redirect(301) every index.php to their root.

For example, this url:

 http://www.example.com/folder/index.php

is redirected to:

 http://www.example.com/folder/

I need a generic rule to avoid .htaccess edit for each new开发者_开发问答 folder.

The .htaccess will be placed on the root of the website.


RewriteEngine On
RewriteRule ^(.*)/?index\.php(\?*.*)$ $1/$2 [L,R=301]

This should take /anyfolder/another/folder/index.php?a=1 and rewrite it to /anyfolder/another/folder/?a=1 (GET variables optional, of course.)

0

精彩评论

暂无评论...
验证码 换一张
取 消