0

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?

Niels Keurentjes
  • 41,402
  • 9
  • 98
  • 136
Himmators
  • 14,278
  • 36
  • 132
  • 223

2 Answers2

0

I think you have 2 options - the "easiest" would be to add a session variable on the server side that shows that all pages returned should be in debug mode. This brings it's own side effects, with reliance on the session being one of them.

The better option is to add the debug query string to all links on the page. This can be done on the server side when the page is rendered, but probably the best way would be to use something like jQuery to automatically add it to all the links (as described here: Jquery : Append querystring to all links)

Community
  • 1
  • 1
Brian Riley
  • 926
  • 1
  • 7
  • 12
0

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.

Niels Keurentjes
  • 41,402
  • 9
  • 98
  • 136