Jump to content

.htaccess RewriteRule HTTPS mod causing 404 errors


dweeda
 Share

Recommended Posts

I installed an SSL Certificate, then edited my .htaccess file:

  # -----------------------------------------------------------------------------------------------
  # 9. If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below.
  # -----------------------------------------------------------------------------------------------
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

by uncommenting out the Rewrite lines.

Now I get 404 error pages when I try go to any .../processwire-master/<pagename>/

This includes my admin page at .../processwire-master/processwire/, so i can't get into my admin.

What else do I need to do?

Link to comment
Share on other sites

I know this may sound strange, but when it comes to https and redirects browsers become very "cachehappy"!

When running into problems with this I use the browsers incognito/private mode, have to empty cache, restart browser, use different browser, use a VPN, and so on.

Tiresome sometimes...

  • Like 3
Link to comment
Share on other sites

I installed an SSL Certificate, then edited my .htaccess file:

  # -----------------------------------------------------------------------------------------------
  # 9. If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below.
  # -----------------------------------------------------------------------------------------------
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

by uncommenting out the Rewrite lines.

The main site loads as https, but now I get 404 error pages when I try go to any subpage: .../processwire-master/<pagename>/

This includes my admin page at .../processwire-master/processwire/, so i can't get into my admin.

After this, in .htaccess I  uncommented out   RewriteBase /   and   RewriteBase /processwire-master/

still not working...

Link to comment
Share on other sites

I haved heard this: 

"I know this may sound strange, but when it comes to https and redirects browsers become very "cachehappy"!

When running into problems with this I use the browsers incognito/private mode, have to empty cache, restart browser, use different browser, use a VPN, and so on.

Tiresome sometimes..."

Hmm.  Does this mean only I continue to see this problem?  External site visitors would be OK?

What can I do to solve this?  Even if only for me...  THX

Link to comment
Share on other sites

Well, there are a lot of folders and files in the /cache/ folder.  I am reluctant to remove them all.  Are there specific files you might have in mind? Or is it truly safe to clear the /cache/ folder?

I am running the latest ver.

Link to comment
Share on other sites

Is there a way to bump this up the PW chain?  I am dead in the water with my production site.  The https config features of the latest ver help with ports to non-https dev sites, not the other way around.

Thank you to any and all!

Link to comment
Share on other sites

My hosting firm says their Apache server is configured correctly. They believe this is a CMS/Framework issue.

I have tried many different .htaccess settings with no effect. 

One theory is that the PW /cache/ folder is the problem and needs to be emptied. But I'm concerned about making things worse with a broad stroke like that. Something more surgical would be better. Yes? No?

Note, all pages were accessible and the site was up and running before I switched to HTTPS. After, only the top domain URL loads. This includes the admin page.

 

Link to comment
Share on other sites

Over the past few weeks I had two new Processwire sites I switched to https using SSL certs from Letsencrypt.  

I had to deal with numerous settings and things with Linux, Apache and my DNS settings (running on a Linode), but at the actual "processwire level" all I had to do was change .htaccess

  # -----------------------------------------------------------------------------------------------
  # 9. If you only want to allow HTTPS, uncomment the RewriteCond and RewriteRule lines below.
  # -----------------------------------------------------------------------------------------------
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

So i can confirm just changing those two lines is sufficient and all pages work.

Not much else I can offer, other than you need to look elsewhere for issues than just those two lines in .htaccess

Edited by Gary Austin
Link to comment
Share on other sites

Yah, I've basically ruled out .htaccess. But there is something preventing the proper resolution to the correct https URL.  I thought it might be something about templates, but the admin page fails too. So - idk... 

I really need to figure this out soon though.

 

Link to comment
Share on other sites

On 22.4.2018 at 5:11 PM, dweeda said:

is it truly safe to clear the /cache/ folder?

Yes and no. Don't delete the site/cache/ folder, but everything inside that folder.

btw, I see your site is showing up fine now. It would be nice to tell us what you or your hosting company finally did to make it work (you know, for other users running into the same problem)

Link to comment
Share on other sites

Well, I have not solved this yet. Unfortunately.

I clicked a host link provided by cstevensjr and modified my .htaccess file appropriately.  No fix.

I also cleared my PW cache folder as per dragan.  But, no fix.

At this point I have tested and made changes for both my host and PW with no effect.  Each is pointing the other way now - so, not unusual :)   Is there a tool my host could use to track what's going on in order to determine the missing and/or problematic link/setting?

Thx to all.

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 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 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 humanafterall
      Hi,
      I would like to set an admin template to 'https only' as recommended in the Processwire security docs.
      However if I do this it forces this setting locally too, resulting in https://localhost requests which result in an error page.
      Is there a simple way round this? Setting https for templates in the config?
      Thanks!
    • 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
    • By Peter Knight
      Can anyone tell me which .htaccess directive might be blocking a site import feature from scanning my public_html folder and listing all files and folders.
      These would be both PW files/folders but also some non PW folders which my PW site references for media.
      Latest .htaccess file on Github
      I can see various options from Section 15 onwards (# 15. Access Restrictions (v301)) but nothing that would block both SSH and FTP scans my VPS site import file uses.
      When I point the same site import tool at a non PW site on the same directory it works.
      I could disable htaccess temporarily but it's a busy and active site.
      Thanks
      P

       
       
×
×
  • Create New...