Categorized | Apache

How to Redirect .php to .html in all of the links pages URL?

you may be in some cases that apearing .php at the end of your links is not apealing to you and you want to do some modification of your URL apearience
after that you had your rewrite rules you then need to have all of the old URLs with .php extenssion to .html to avoid any broken links and lowering your SEO reputation
you just need to add the following code into your .htaccess near the other rule.

RedirectMatch 301 (.*)\.php$ http://www.example.com$1.html

what thsi rule does is so easy to understand that in the begining it has a rewrite match rule with 301 number that is the specification of permanent redirect and the rest is the rule to be aplied with regular experession
this will match every link that has the .php at the end of it with relative url that will be aplied to every linking policy even with www. or without it to redirect it to .html .
the example.com part will be vary according to your domian name.

to have a revers action like that to redirect .html to .php you just need to change the .html and .php location in the rule
such as the following:

RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php

Related posts:

  1. How to redirect WWW to non-WWW
  2. HotLink protections tutorial

Leave a Reply

Plese subscribe to my newsletter

Please subscribe via your email to follow me

E-mail:

Subscribe
Unsubscribe