Redirect through htaccess

Asked

Viewed 101 times

1

I migrated from one site to another server. On the current server, all posts on the site had an index.php in the link www.MEUSITE.com.br/index.php/test

on the new server I want to stay www.MEUSITE.com.br/test

can do this for .htaccess or PHP?

1 answer

1


Could do so :

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

Redirect the url that contains after the domain index php. escaping the point with backslash, preceded by / (bar), and a set of characters delimited in my expression by : (.*)

or

could also ride this way, where is (.*) put so:

([a-z0-9_\-]+)

but only works with the characters marked in the expression that are to until z numbers of 0 until 9 the character underline and the trait, that in case it is of a special nature we use a backslash before to escape it, could adapt their needs.

RewriteRule ^index\.php/([a-z0-9_\-]+)$  /$1  [L,R=301]

The [+] indicates that it may be, one or a combination of characters in the expression.

The [L] is last, that is, in a list of conditions, the conditions below the one with this flag will not be read.

The [R] is redirect, it commands the browser to do the redirect You need to put the full URL.

In your case I’m using the HTTP STATUS 301 to take the url relevance in serps to the new url.

I believe the expression is correct. I didn’t do any tests, I hope it’s useful, hugs.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.