htmlquery-stringgetparameter

Can you somehow use the base-tag to pass parameters?


I written some custom debugging code to a large framework, by adding ?debug to any url I get some custom server-data. Whenever I click a link, the ?debug disapears, ofcorse can I keep it there somehow? My idea was using the base-tag:

If(isset($_POST['debug']{
    <base href="/images/">
}

But it doesn't seem to support parameters. Is there something similair?


Solution

  • Assuming you're using Apache you could just use mod_rewrite:

    RewriteEngine on
    
    # Test whether the current query string contains 'debug'
    RewriteCond %{QUERY_STRING} !debug
    
    # Internally append ('query string append') the extra parameter
    RewriteRule (.*) $1?debug [QSA]
    

    To limit this behaviour to only your computer add an extra condition in between:

    # Only trigger the rule if the remote IP address exactly matches the string
    RewriteCond %{REMOTE_ADDR} =192.168.1.1
    

    And replace the IP with your own.