Unwanted redirect for subpages

Using Modx 2.8.1, I am running a website on this url as root element / homepage: mypage.com/myhomepage
I was asked to add further subpages which should be accessible like this: mypage.com/myhomepage/subpage1, mypage.com/myhomepage/subpage2 and so on.

Ever since I create these subpages and prepared everything for friendly urls, once I open these subpages, I will be redirected to mypage.com for some strange reason.

  • the status of the subpages is “published”

  • I cant access the page neither by directly typing the url to the browser manually nor by clicking the “preview” button in modx

  • modx error log does not contain any error

  • all affected subpages contain the neccessary meta tag:
    <base href="[[!++site_url]]" />

  • I cleared the cache several times

  • as for modx settings, I set “friendly_urls” and “use_alias_path” to yes

  • this is everything my .htaccess file in root contains:


RewriteEngine On
RewriteBase /

RewriteRule "^\.well-known/" - [L]
RewriteRule "/\.|^\.(?!well-known/)" - [F]

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# The Friendly URLs part
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

Still, I can’t open my newly created subpages and am always being redirected to page root "mypage.com". What am I missing? Any other hints?

I don’t quite understand.

Is MODX installed in a subfolder with the name “myhomepage”?
Then you have to change the RewriteBase in the .htaccess:

RewriteBase /myhomepage/

If (on the other hand) “myhomepage” is the alias of a resource in MODX, then maybe try setting the system setting use_alias_path to Yes.

I forgot to mention that “use_alias_path” was already set to yes (updated my question).

Apart from that, you are right, assuming that modx is installed in a folder called “myhomepage”. I updated the .htaccess file accordingly (RewriteBase /myhomepage/) but still get the same error.

  • In the database table modx_site_content check the column uri to see if the content is correct.
  • Try if it works when you call the page mypage.com/myhomepage/index.php?q=subpage1.html, where you add the value from the uri column as the request parameter q. If that works, then the problem is the .htaccess file.

The solution with

RewriteBase /myhomepage/

assumes that the .htaccess file is located in the myhomepage subfolder.

Yes, it is.
I got it working now, meaning, I can access the subpage by manually typing the url to the browser (mypage.com/myhomepage/subpage1) but still not by using the preview button in Modx!? Good enough for now, yet, it would be interesting to know whats still crashing the preview button.

What is the difference in the URL that works (mypage.com/myhomepage/subpage1) and the URL that the “View” button generates?

In the file core/config.inc.php, are the paths set correctly? (E.g. the variable $modx_base_url is set to /myhomepage/ etc.)

Yes, it is set correctly.

Unfortunately, I can’t tell. When clicking the view button, the browser opens the page with the correct url, but does not show any content, remains in that loading state for about 2 seconds and then performs the redirect. I tried canceling the loading process and viewing the page content via the inspector but the page is blank.

Update: I think, in the end, there was something wrong with my resources, too. I deleted the old resources of the subpages, recreated them, reassigned the templates and now even the view button seems to work. I guess, there was something corrupt along the way after all the changes of the settings.

Anyhow, thanks very much for your support, harry. Life saver award hereby officially handed over =)
Cheers.

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.