Remove "php" from "js.php" files - .htaccess

Discussion in 'Apache' started by publicidadpixelada, Feb 11, 2007.

  1. #1
    Hi!

    I have a question regarding the .htaccess file.

    I have several files named something.js.php that look like this:

    <?php
    header("Content-type: text/javascript; charset: UTF-8");
    ?>
    //javascript starts here
    function something() {
         document.write('Hello');
    }
    Code (markup):
    My question is... How do I remove the .php extension with the .htaccess file? So the file would be called like something.js and still being parsed as php by my server

    Thanks a lot!
     
    publicidadpixelada, Feb 11, 2007 IP
  2. Your Content

    Your Content Banned

    Messages:
    1,096
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your Content, Feb 11, 2007 IP
  3. ablaye

    ablaye Well-Known Member

    Messages:
    4,024
    Likes Received:
    97
    Best Answers:
    0
    Trophy Points:
    150
    #3
    Add this to your htaccess file:

    RewriteRule ^(.*).js$ ${1}.js.php [nc]
     
    ablaye, Feb 11, 2007 IP
  4. publicidadpixelada

    publicidadpixelada Peon

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks a lot! Worked like a charm!

    Just a quick fix, to make it work I had to put it like this:

    RewriteRule ^(.*).js$ $1.js.php [nc]
    Code (markup):
     
    publicidadpixelada, Feb 11, 2007 IP