Redirect through htaccess

1

I migrated from one site to another server. On the current server, every site post had an index.php on the link www.meusite.com.br/index.php/teste

On the new server I want to either stay www.meusite.com.br/teste

Can you do this for .htaccess or PHP?

    
asked by anonymous 19.07.2017 / 03:31

1 answer

1

I could do this:

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

Redirect the url that contains after the index.php domain by escaping the backslash, preceded by / ( slash ), and a delimited character set in my expression by: (. *)

or

could also put it this way, where it is (. *) put like this:

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

but only works with the characters marked in the expression that are a up to z 0 numbers up to 9 the underline character and the trait , which in the case because it is a special character we use a backslash before escaping it, could adapt your needs.

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

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

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

[R] is redirect, this directs the browser to do the redirect. You need to put the full URL.

  

In your case I'm using HTTP STATUS 301 to take the relevancy of the url in the serps to the new url.

I think the expression is correct. I did not test , I hope it's useful, hugs.

    
19.07.2017 / 07:27