简体   繁体   中英

.htaccess redirect a broken link domain.com/.php

i need to redirect the broken url like

domain.com/.php to domain.com/index.php

anyone know how??i try to use some htaccess generator like

http://htaccessredirect.net/index.php

and get this code but redirect loop/error

i have tried the following code,but not work

Redirect 301 /.php index.php

and also i tried, but error

RewriteCond %{HTTP_HOST} ^/.php$
RewriteRule ^$ index.php [L,R=301]

You need to escape the period or it becomes part of the regular expression.

Like this:

RewriteRule ^/\.php$ /index.php [L,R=301]

or:

RedirectMatch 301 ^/\.php index.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM