Using htaccess to get rid of /index.php link?

coderama

I can open my site like this:

www.mysite.com

or like this:

www.mysite.com/index.php

I want to create a htaccess rule that redirects www.mysite.com/index.php to www.mysite.com. But all my attempts have other side effects. I've tried:

Redirect index.php    home.php
RewriteRule    ^index.php?$    home.php    [NC,L]
RewriteRule    ^index.php/?$    redirect_to_home.php    [NC,L]

But all of these mess up the original index.php call. So it does redirect but then the normal mysite.com link doesnt work anymore.

Any ideas?

anubhava

Use this redirect rule to remove /index.php from any path:

RewriteEngine On

RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteCond %{REQUEST_URI} ^(.*/)index\.php$ [NC]
RewriteRule ^ %1 [L,R=301,NE]

Este artigo é coletado da Internet.

Se houver alguma infração, entre em [email protected] Delete.

editar em
0

deixe-me dizer algumas palavras

0comentários
loginDepois de participar da revisão

Artigos relacionados

TOP lista

quentelabel

Arquivo