Test links

All links shown below should point to this file

Matches the rewrite rule without a number:

/rewrite/test
/rewrite/test/
/rewrite/test?a=1
/rewrite/test/?a=1

Matches the rewrite rule with a number:

/rewrite/test/1234
/rewrite/test/1234/
/rewrite/test/1234?a=1
/rewrite/test/1234/?a=1

$_GET

Current GET parameter list. The number will be the "id" parameter. Any custom parameters will be present too.

{
    "a": "1"
}

.htaccess

Content of the local .htaccess file

#Rewrite requests for "test/<number>" (with optional trailing slash)
#QSA: The query string is appended properly if it's present.
#NC:  Case insensitive regex match
RewriteRule ^test/(\d+)/?$ index.php?id=$1 [QSA,NC]

#Rewrite requests for "test" itself (with optional trailing slash)
#QSA: The query string is appended properly if it's present.
#NC:  Case insensitive regex match
RewriteRule ^test/?$ index.php [QSA,NC]

index.php

Source code of this file itself

<?php

    
function he($x){return htmlspecialchars($x);}
    function 
h1($x){echo '<h1>' he($x) . '</h1>';}
    function 
a($x){echo '<a href="' he($x) . '">' he($x) . '</a><br />';}
    function 
p($x){echo '<p>' he($x) . '</p>';}

    
h1('Test links');
    
p('All links shown below should point to this file');
    
    
p('Matches the rewrite rule without a number:');
    
a('/rewrite/test');
    
a('/rewrite/test/');
    
a('/rewrite/test?a=1');
    
a('/rewrite/test/?a=1');
    
    
p('Matches the rewrite rule with a number:');
    
a('/rewrite/test/1234');
    
a('/rewrite/test/1234/');
    
a('/rewrite/test/1234?a=1');
    
a('/rewrite/test/1234/?a=1');

    
h1('$_GET');
    
p('Current GET parameter list. The number will be the "id" parameter. '.
        
'Any custom parameters will be present too.');
    echo 
'<pre>' he(json_encode($_GET,JSON_PRETTY_PRINT)) . '</pre>';

    
h1('.htaccess');
    
p('Content of the local .htaccess file');
    echo 
'<pre>' he(file_get_contents('.htaccess')) . '</pre>';

    
h1('index.php');
    
p('Source code of this file itself');
    
highlight_file(__FILE__);