Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Am using CakePHP, how can I remove /app/webroot/ in all my links?

edited September 2011 in Vanilla 2.0 - 2.8
tried many things.. and $Configuration['Garden']['WebRoot'] doesn't seem to work.
Tagged:

Best Answer

Answers

  • Options
    Yes if you look at the code it isn't complete. I brought it up before.

    grep is your friend.

  • Options
    x00x00 MVP
    Answer ✓
    I will start an issue on github

    grep is your friend.

  • Options
    thanks @x00 i can stop looking for now..
  • Options
    Yep a slight pain. it is sort of half done, left hanging.

    grep is your friend.

  • Options
    @x00 do you know whether it can be hardcoded?
    in wordpress there is a field which you can input the webroot, which can also be changed in the database..
  • Options
    x00x00 MVP
    edited September 2011
    sure it turns out to be a typo in code

    simply in libary/core/class.request.php find
    $this->_EnvironmentElement('ConfigStrips', Gdn::Config('Garden.StripWebRoot', FALSE))
    replace it with
    $this->_EnvironmentElement('ConfigStripUrl', Gdn::Config('Garden.StripWebRoot', FALSE))

    config like so
    $Configuration['Garden']['WebRoot'] = 'path/to/web/app';// you want to strip note no preceding or trailing slash. $Configuration['Garden']['StripWebRoot'] = TRUE;

    grep is your friend.

  • Options
    LincLinc Detroit Admin
    I've fixed in the active branch and asked Tim to review it for me.
  • Options
    don't close it yet I'm going to suggest a slightly refined version.

    grep is your friend.

  • Options
    x00x00 MVP
    edited September 2011
    public function WebRoot($WebRoot = NULL) { $Path = (string)$this->_ParsedRequestElement('WebRoot', $WebRoot); $WebRootFromConfig = $this->_EnvironmentElement('ConfigWebRoot'); $RemoveWebRootConfig = $this->_EnvironmentElement('ConfigStripUrls'); if ($WebRootFromConfig && $RemoveWebRootConfig) {//strip code //don't worry about trailing preceding slashes/spaces $WebRootFromConfig = trim($WebRootFromConfig,'/ '); //case insensitive strip, once and from the beginning $Path = preg_replace('#^'.$WebRootFromConfig.'#i', '', $Path); } return $Path; }

    if you change the directory structure remember to clear the cache

    grep is your friend.

  • Options
    x00x00 MVP
    edited September 2011
    also why don't you store result so this only gets called once per request.

    It could also be possible to auto strip, which would make it more transportable.

    grep is your friend.

Sign In or Register to comment.