xhgui icon indicating copy to clipboard operation
xhgui copied to clipboard

xhgui and relative paths

Open vad1m opened this issue 11 years ago • 8 comments

Hi all,

I tried setup xhgui at our main host at additional location /xhgui.

I tried a lot of configurations with nginx, but I'm able only to load main page. All links inside page (to js, css, as well as links to menu items) are relative and pointed to absolute website root (/js/...), instead of relative current root (/xhgui/js...). Do you have any special config option to set base path for xhgui (like HTTP_BASE = http://oursite.com/xhgui/) ? Or maybe you can suggest another solution for that?

Otherwise that feature could be very useful.

Thanks!

vad1m avatar Oct 01 '15 13:10 vad1m

Currently there isn't a way to configure a base path. Adding one sounds like a good idea though.

markstory avatar Oct 01 '15 21:10 markstory

I was able to setup XHGUI in a virtual directory by simple changing the rewrite rules in web.config.

The only change is to remove the leading slash in /index, and add to keep the virtual directory from inheriting rewrite rules from the parent site.

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <clear/>
        <rule name="rule 1n" stopProcessing="true">
          <match url="^" />
          <action type="Rewrite" url="index.php" appendQueryString="true" />
          <conditions>
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
          </conditions>
        </rule>
      </rules>
    </rewrite>
    <handlers configSource="handlers.config" />
  </system.webServer>
</configuration>

david-garcia-garcia avatar Oct 31 '15 17:10 david-garcia-garcia

Hi @markstory,

I also wanted to commit my changes related to saving not only relative urls, but full/absolute urls. Example: /contact-us path will be saved as example.com/contact-us.

I use xhgui on multi-website project and I need full urls on xhgui profiling. Should I make this feature enable/diaable via config?

davronbek avatar Nov 27 '15 08:11 davronbek

I ran into the same problem and tried to work around it with Alias/Rewrite before discovering this issue here.

I changed a few lines of code and now it works for me. I am not sure, if this is the best practice, but the usage of the 'static' function inside Twig-Templates seems pretty limited, so i guess it won't break stuff.

I can create a pull request for it, but maybe it is better to discuss this first.

src/Xhgui/Twig/Extension.php:73

public function staticUrl($url)
{
    $rootUri = $this->_app->request()->getRootUri();

    // get URL part prepending index.php
    $indexPos = strpos($rootUri, 'index.php');
    if ( $indexPos > 0 ) {
        return substr($rootUri,0,$indexPos) . $url;
    } else {
        return $rootUri . '/' . $url;
    }
}

noreabu avatar Apr 05 '16 15:04 noreabu

@noreabu That code seems pretty reasonable to me.

markstory avatar Apr 05 '16 16:04 markstory

Ok, i will create a pull request later.

noreabu avatar Apr 05 '16 16:04 noreabu

Awesome!

markstory avatar Apr 06 '16 01:04 markstory

My Mailserver is currently "on vacation" so it will take some more time to retrieve my github pw to this machine... but don't worry the pull request will be there shortly after :)

noreabu avatar Apr 06 '16 12:04 noreabu