Originally reported by @mdrummond

I had a test site installed, so that when I accessed it in the browser I did so at localhost/amptest/docroot

On the AMP config page, the link to the test library page returned a 404. Here you can see the URL showing for the button.

The link is to localhost/admin/amp/library/test. However, based on the Drupal installation location, it should be localhost/amptest/docroot/admin/amp/library/test in order for the link to work.

The code for this is in AmpSettingsForm.php around line 191:

    $form['test_page'] = array(
      '#type' => 'item',
      '#markup' => t('<a href="/admin/amp/library/test">Test that AMP is configured properly</a>'),
    );

Rather than hard-coding an absolute URL there, something needs to be put in there so the Drupal root location is added to the URL if necessary.

I had a similar error on a node edit page, when I pressed the `Save and View AMP` button. That is generated in amp.module around line 297:

  $path = $form_state->getValue('path');
  $url = !empty($path[0]['alias']) ? $path[0]['alias'] : $path[0]['source'];
  if (isset($url)) {
    $amp_path = $url . "/amp";
    $response = new RedirectResponse($amp_path);
    $response->send();
  }

Again, maybe something needs to be put in there to make sure the URL includes the drupal root if necessary.

Those are the only hard-coded URLs I have found so far, but if we can think of any others might be worth checking those.

Comments

sirkitree created an issue. See original summary.

mtift’s picture

Assigned: Unassigned » mtift
mtift’s picture

Status: Active » Fixed
Issue tags: +AMP: 3/18 (D7 complete)

  • mtift committed 27e5409 on 8.x-1.x
    Issue #2678990 by mtift: Look at hard-coded URLs to ensure they work...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.