Jump to content

PW in subdirectory


hellomoto
 Share

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.

Link to comment
Share on other sites

Normally you just have to customize RewriteBase.

http://processwire.com/docs/tutorials/troubleshooting-guide/page3

(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
Link to comment
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

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By Gazley
      Hi there! It's been a long time since I've been here. I've not developed for a good few years. My son has asked if I can create him a website for his personal training service. I used to have a Linode to host sites but I've not had that for a while. Also, it was a bit problematic being responsible for the web server and general setup. I wondered what the best/easiest way is to quickly establish hosting without the hassle? Something where the setup and PW installation is automatically handled? 
      Any ideas or suggestions would be very much appreciated! 👍
      Cheers.
    • By wwwouter
      Some context: I want to use PHP variables in my CSS (more info below) and found a solution on CSS-tricks that looks fairly elegant and somewhat solid to me. It's pretty simple, I created a file style.css.php inside the site/templates/ directory and load that in my page head. In style.css.php is the following:
      <?php header("Content-type: text/css; charset: UTF-8"); header("Charset:utf-8"); if ($homepage->hero_image) { echo <<<CSS .hero { background: url($homepage->hero_image->url) no-repeat; } CSS; } ?> Because of the following RewriteCond (line 373) in the htaccess file the server sends a 403 error back when the file is requested:
      # Block access to any PHP or markup files in /site/templates/ or /site-*/templates/ RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))($|/) [NC,OR] (My htaccess file is @version 3.0 and @htaccessVersion 301)
      This is how I thought I could fix that (based on these answers on stack overflow) but it does not work:
      # Block access to any PHP or markup files in /site/templates/ or /site-*/templates/ RewriteCond %{REQUEST_URI} (^|/)(site|site-[^/]+)/templates($|/|/((?!style\.css).)*\.(php|html?|tpl|inc))($|/) [NC,OR] I tested the rule with htacess tester and htaccess check and both worked for me, but on my site I still get a 403 instead of the file.
      I'm working on localhost, using MAMP (not sure if that's relevant).
      A bit more about what I want to do achieve specifically:
      I want to use an image as a background-image for an element, not place it as an image. This image is provided by the user via a field and can therefore change.
      I know I can achieve this like this:
      echo "<section class='hero' style='background-image: url($page->hero_image->url)'></section>"; But I would prefer a method other than inlining because of scalability and cleanliness. (I admit the extra link in the page head is not ideal either)
       
      P.s. this is my first post here, I hope it's submitted in the right forum and my explanation is clear.
    • By prestoav
      Hi there, I'm hoping someone can help here.
      I've just moved a new site from my development server account over (where the site was working fine for the client to edit content pre-launch) to the client's final hosting account and the live site is all fine. However, while most edits can be done without an issue, image uploads in admin cannot. I know this has been an issue before but, having trawled the posts about it and suggested esolutions I still can't resolve it on their host.

      PW Version: 3.0.123
      PHP version: 7.3.20
      max_execution_time 160
      max_upload_size 256M
      GD Library is enabled

      Looking at the console data it looks like the AJAX request from the image upload is getting a 403 error which is suggesting a permissions issue? First we get this on console:
       
      ?id=1169&s=1&c=1:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0 Then, the AJAX request:
       
      https://*******/admin/page/edit/?&id=1169&InputfieldFileAjax=1 Gets a 403 according to Chrome Dev Tools > Network XHR. Also, the response is empty.

      Can anyone point me in the direction of the directory that deals with this and what the permission should be to allow it or indeed any other fix / area to investigate?

      Thanks so much for your help.

       
    • By RDC
      Is the right way to get Processwire to skip a folder (ie not process it as its running a different CMS) to put
      RewriteCond %{REQUEST_URI} !^/shop/.*$
      just before 
      RewriteRule ^(.*)$ index.php?it=$1 [L,QSA]
      in .htaccess?
    • By Spiria
      I am writing here instead of the ProCache forum because I have the impression that several nginx experts could solve this. In its new version, Procache proposes new .htaccess rules that are difficult to translate into nginx rules. We currently have a problem with the trailing slash of URLs which gives us a bad score in SEO analysis tools such as semrush.com. 
      Indeed, a canonical URL is either without or with "/", but cannot be served by both options. Although ProcessWire without ProCache respects this rule, ProCache has no difficulty serving both, which is considered an SEO optimisation fault. I believe that ProCache version 2 solves this problem with these new rules, but I can't understand the following. Does anyone have any idea how to translate this into a nginx rule?
      Attached also the whole proposed .htaccess for ProcessWire.
      # PROCACHE v2/31885be14d6cfb4b2b0d3e533260bded -------------------------------------------------- RewriteCond %{REQUEST_METHOD} !=POST RewriteCond %{QUERY_STRING} !.*=.* RewriteRule ^.*/$ - [E=pwpcstep:pour,E=pwpcname:index] RewriteCond %{ENV:pwpcstep} "=pour" RewriteCond %{HTTP_COOKIE} !^.*(wire_challenge|wires_challenge).*$ RewriteRule ^.*/$ - [E=pwpcstep:stir,E=pwpcpath:%{DOCUMENT_ROOT}/site/assets/ProCache-00478359c5e65dbada1075bfbd4] RewriteCond %{ENV:pwpcstep} "=stir" RewriteCond %{ENV:pwpcpath}/$0/%{ENV:pwpcname}.html -f RewriteRule ^.*$ - [E=pwpcstep:drink,E=pwpcfile:$0/%{ENV:pwpcname}.html] RewriteCond %{ENV:pwpcstep} "=drink" RewriteRule ^(.*) %{ENV:pwpcpath}/%{ENV:pwpcfile} [L] <ifModule mod_headers.c> Header set X-PWPC "ProCache" env=pwpcstep Header set X-Powered-By "ProcessWire CMS, ProCache" env=pwpcstep </ifModule> RewriteCond %{REQUEST_URI} "^/~?[-_.a-zA-Z0-9/]*$" # /PROCACHE -------------------------------------------------------------------------------------  
      .htaccess-procache
×
×
  • Create New...