1

This is my .htaccess

RewriteEngine On

RewriteRule ^(.*)\.js?$ index.php?js=$1&key=$2

Original URL

/index.php?js=myscript&key=mykey

The Rewritten URL

/myscript.js?key=mykey

The PHP Source

$kunci = @$_GET['key'];

if (isset($kunci))
            {
            if ($kunci == "xxx")
                {
                echo $abc;
                }
              else
                {
                echo $def;
                }
            }
    else{
        echo $ghi;
    }

How to RewriteRule Original URL to Rewritten URL?

When I type I want domain.com/myscript.js?key=123 get page and domain.com/myscript.js get page too like condition in PHP source above

Hedi Herdiana
  • 101
  • 1
  • 11
  • Possible duplicate of [redirect all .html extensions to .php](https://stackoverflow.com/questions/5990240/redirect-all-html-extensions-to-php) – Pyromonk May 31 '17 at 00:06

1 Answers1

0

Try with below rule,

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/app/coba/([^/]+)\.js$
RewriteCond %{QUERY_STRING} ^key=([^/]+)$
RewriteRule ^ index.php?js=%1&key=%2 [L]
Abhishek Gurjar
  • 7,426
  • 10
  • 37
  • 45