Question: How can i redirect html page extensions to php using proper htaccess redirect as similar to this <http://www.hd2wallpapers.com/butterfly_green-wallpapers.html> gets redirected to <http://www.hd2wallpapers.com/butterfly_green-wallpapers.php>.

Answer: 
Here's yet another way to do something similar with a class decorator—but the aliases aren't specified within the class body like you wanted. It's *very* similar to @BrenBarn's [answer](https://stackoverflow.com/a/19651294/355230), except the aliases are decorator arguments—which I think might be more desirable for some types of usage (and it seems more explicit since it makes them more conspicuous that way).

```
import sys

def aliases(*pseudonyms):
    def aliaser(cls):
        namespace = sys._getframe(1).f_globals  # Caller's globals.
        namespace.update({alias: cls for alias in pseudonyms})
        cls.aliases = pseudonyms
        return cls
    return aliaser

if __name__ == '__main__':
    @aliases('SN', 'FUBAR')
    class LongName(object):
        pass

    print(SN)                # <class '__main__.LongName'>
    print(FUBAR)             # <class '__main__.LongName'>
    print(LongName.aliases)  # ('SN', 'FUBar')

```

#### Update

The [PEP 487](https://www.python.org/dev/peps/pep-0487/) was implemented in Python version 3.6 which allows class customization through inheritance via a new [`__init_subclass__()`](https://docs.python.org/3/reference/datamodel.html#object.__init_subclass__) hook. The code below shows how the same thing could be done using using it.

```
class AKA:
    """ An 'Also Known As' baseclass that allows subclasses to give themselves
        aliases.
    """
    def __init_subclass__(cls, /, aliases=(), **kwargs):
        super().__init_subclass__(**kwargs)
        cls.aliases = aliases
        globals().update({alias: cls for alias in aliases})

if __name__ == '__main__':

    class LongName(AKA, aliases=('SN', 'FUBAR')):
        pass

    print(SN)                # <class '__main__.LongName'>
    print(FUBAR)             # <class '__main__.LongName'>
    print(LongName.aliases)  # ('SN', 'FUBar')

```
It's a bad idea, but it can be done with an abuse of class decorators:

```
def aliaser(cls):
    for alias in cls.aliases:
        globals()[alias] = cls
    return cls

@aliaser
class LongName(object):
    aliases = ['LN', 'Ugh']

>>> LN
<class '__main__.LongName'>

```

This is an abuse because the point of decorators is to modify the object they decorate, but this one is used only for its global side-effect of assigning additional names in the global namespace that point to the same class.

Use at your own risk! ;-)