Jump to content

PW in subdirectory

Recommended Posts

I have web hosting with the following .htaccess en root, to point it to a subdirectory "audino.us", wherein I have PW installed:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?something.com$
RewriteCond %{REQUEST_URI} !^/something.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /audino.us/$1
RewriteCond %{HTTP_HOST} ^(www.)?something.com$
RewriteRule ^(/)?$ something.com/index.php [L]

RewriteCond %{HTTP_HOST} ^(www.)?something.com$
RewriteRule ^(/)?$ something.com [L]

However when I go to audino.us/pw to access the admin, it becomes audino.us/audino.us/pw, and doesn't allow me to log in. How do I render the above to be recursive (?), i.e., to apply to all subordinate URLs? Is this to be done within the .htaccess in /audino.us, or in the root .htaccess above? Please help, I can't log in. Thanks much.

Share this post

Link to post
Share on other sites

Normally you just have to customize RewriteBase.


(Or) doesn't your hosting provider ("panel") allow you to point your website to a sub-directory?

NB: http://domainname.tld/index.php should redirect to http://domainname.tld/, shouldn't it?
And, for SEO at least, the non-www version should redirect to the www version (or the contrary). Perhaps you have planned to do it later.

PS: for security reasons, perhaps you should "hide" the domain name of your website if it's still in development mode.

  • Like 1

Share this post

Link to post
Share on other sites

I have RewriteBase / in the PW htaccess, so / but:

  • / => example.com
  • /pw => example.com/example.com/pw/
  • /pw/ => example.com/pw/ ^-^
  • www. => www.example.com/example.com/
    (root links also = "", as opposed to www.example.com


How can I fix this?

root .htaccess =

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(www\.)?example\.com/?(.*)$ http://example.com/$1 [R]
RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /example.com/$1 [L,QSA]

 oh and so much for hiding the domain I did just because you said but you didn't but that's a ok

Share this post

Link to post
Share on other sites

Now I have 

RewriteEngine on
RewriteBase /

RewriteRule ^index.php$ / [NC,R,L]

# remove double/more slashes in url
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?audino\.us$ [NC]
#RewriteBase /audino.us
RewriteRule !^audino\.us/ /audino\.us%{REQUEST_URI} [L,NC]
# above 2 lines same effect

and in site/ready.php $config->urls->root = '/'; thus:

  • ^(www.)?example.com => example.com/example.com/
  • ^(www.)?example.com/pw, ^(www.)?example.com/pw/ => example.com/pw/

How to remedy this?
Also I am still unable to login; I've tried resetting the password via API in case I had it wrong.

Share this post

Link to post
Share on other sites

Please try with a fresh .htaccess file (in the sub-directory(?)). Disable the (lines you have added in the) .htaccess file you have in the root(?).

# 11.

RewriteBase /audino.us/

# 13.

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

If you want to redirect to the "www." version of the site (and not the opposite).

Don't put anything in ready.php related to this problem.

With some web hostings you can just point the website to a sub-directory from within their administrations. You don't need to touch RewriteBase.

Share this post

Link to post
Share on other sites

Christophe: that line #11 you mention is commented out in [public_html/].htaccess. The www I hadn't yet decided whether to force or omit.

How do I prevent / from rendering the URL as /audino.us/? 

Share this post

Link to post
Share on other sites
RewriteEngine on
RewriteBase /

RewriteRule ^index.php$ / [NC,R,L]

RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]

# mask primary domain subdir. location
RewriteCond %{HTTP_HOST} ^(www\.)?audino\.us$ [NC]
RewriteRule ^(.*)$ /audino\.us%{REQUEST_URI} [L,NC,QSA]

The above seems effective overall, except that (www.)?example.com/example.com(.*) need hide that tricky subdirectory from the URI.

Also I need to know how to either force or omit the www. prefix while also pointing to & hiding the subdirectory serving the site.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Peter Knight
      Hi all
      My .htaccess file is correctly redirecting all requests to
      https:// www. That's great until I want to work locally.
      I thought I had seen a blog post by Ryan where there was a new config setting to ignore both of these if working from localhost?
      I can't find it now so wondering if I was imagining 😕
    • By Robin S
      Add Image URLs
      Allows images/files to be added to Image/File fields by pasting URLs.

      Install the Add Image URLs module.
      A "Paste URLs" button will be added to all image and file fields. Use the button to show a textarea where URLs may be pasted, one per line. Images/files are added when the page is saved.
    • By Guy Incognito
      Have read loads of similar threads but can't find the deifnitive answer. I'm bootstrapping ProcessWire into a Magento installation. Everything is working fine in terms of expected PW API functionality, however I cannot get the paths for images in the site work correctly.
      ProcessWire is installed in a subfolder called 'pw'.
      If I load the PW site directly e.g. visit mainsite.com/pw everything loads fine and all image paths are correct. If I load the parent site in the root folder with the PW bootstrapped page content rendered within it, the image paths don't contain the subfolder and so are broken. So I get
      https://mainsiteexample.com/site/templates/img/test.jpg instead of
      https://mainsiteexample.com/pw/site/templates/img/test.jpg I've tried updating the rewrite base in the .htaccess file but it doesn't seem to make any difference. Have also tried various settings in the config file to no avail. Wondering if rewrite base perhaps isn't working as intended because I'm behind a NGINX/Apache hybrid environment?
    • By ajt
      I want to keep sort some pages in my page tree within a single parent, but then have the URLs for those pages ignore their topmost parent.
      So for example, if the page is at: [home]/buildings/architect-name/building-name
      I want the URL to be /architect-name/building-name
      I've search around the forum, and the solution that comes up everywhere is a version of the code from this post: 
      /** * This hook modifies the default behavior of the Page::path function (and thereby Page::url) * * The primary purpose is to redefine blog posts to be accessed at a URL off the root level * rather than under /posts/ (where they actually live). * */ wire()->addHookBefore('Page::path', function($event) { $page = $event->object; if($page->template == 'post') { // ensure that pages with template 'post' live off the root rather than '/posts/' $event->replace = true; $event->return = "/$page->name/"; } }); And I can use a version of that to successfully get buildings/architect-name to appear as /architect-name
      But /buildings/architect-name/building-name still appears as /buildings/architect-name/building-name
      Is there a way to get URLs to ignore/remove that topmost parent even when the page has a grandchild?
      Any help much appreciated!
    • By ce90
      Hello everyone,
      hopefully this is the right place to ask and is not a duplicate question.
      I'm pretty new to processwire, so... if this question is kind of funny for some of you, you're welcome 😄 
      I have the following issue and can't find anything understandable about it. Maybe I'm searching the wrong way, but anyways.. here is my question:

      How is it possible to rewrite the URLs, that I'll get a *.php ending?
      https://www.mysite.de/urlsegment/ -> https://www.mysite.de/urlsegment.php
      https://www.mysite.de/urlsegment/urlsegment/ -> https://www.mysite.de/urlsegment/urlsegment.php
      Because I've read a lot about "Why do you wanna do this or have that?" – here my answer for that in advance:
      I've built a processwire installation inside or around an existing website. Therefore, we want to keep the existing *.php Google entries. Sure, we could redirect via 301 Redirect, but would prefer to keep the *.php ending.
      If you have further questions, please do not hesitate to ask.
      Thank you in advance for your help.

      Best regards
  • Create New...