Jump to content
4ldesigns

.htaccess Causing a 403 Forbidden Error in Sub/Add-On Domains

Recommended Posts

G'day everyone :)

I'm new to ProcessWire - hoping someone could help me out??

I've installed ProcessWire in my root (public_html) directory & all is good - I really like this CMS. Very happy I stumbled across it! Thank you!

This processwire site is accessible from my main domain (www.example.com) - No problem.

However... I also own another domain name which I want to use for an entirely seperate website, but hosted on the same server account.

Now, I've done this before with basic web pages with no hassles. But, with ProcessWire already installed - I'm having issues?

In my cPanel admin area I create an Add-On Domain (www.secondwebsite.com).

This creates a new folder in the root e.g. public_html/secondwebsite.com, and also creates the subdomain secondwebsite.example.com (which I'll deal with later).

So, I place a Hello World index.html file within the new public_html/secondwebsite.com folder - This is to be the front page of my second website (entirely seperate from the ProcessWire site).

When I type www.secondwebsite.com in my web browser, it is supposed to load that index.html file...

Instead, I am greeted with a 403 Forbidden Error:

Forbidden

You don't have permission to access /
on this server.

Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.

Apache Server at www.secondwebsite.com Port 80

Spewing.

I did a bit of Googling to try and find a solution and found this thread which seems to have the answer, but I just can't figure out how to apply it to ProcessWire?

I applied the fix they suggest in that thread by adding:

RewriteCond %{HTTP_HOST} ^(www\.)?secondwebsite\.com
RewriteRule .* - [L]

To the start of the .htaccess file in my public_html folder. No luck.

I tried placing it in different areas of the file, such as after the ReWriteEngine on line... Still no luck.

Now, I've verified that it is the ProcessWire .htaccess file which is causing the issue, as I renamed the file, and I was instantly able to access my Add-On Domain from www.secondwebsite.com

Could someone PLEASE help me out with this issue? I really don't have much experience with .htaccess files.

If I can't resolve this it messes up my website plans for using ProcessWire :(

Any help is greatly appreciated, thanks.

Nick

Share this post


Link to post
Share on other sites

OK, I **think** I have found a solution / work-around for my issue.

I found it when searching the ProcessWire forums, I stumbled across this post: http://processwire.com/talk/topic/1295-problems-setting-up-multisite/?p=11542

Ryan mentions that the .htaccess blocks access to any directory that doesn't begin with 'site-' for security purposes.

So, I simply deleted my add-on domain and re-added it with 'site-' at the start of its folder name.

e.g. public_html/site-secondwebsite.com

I can now leave my default .htaccess created by ProcessWire in the public_html directory, and now access a basic Hello World .html file in my add-on domains directory from the add-on domains URL: www.secondwebsite.com - YAY!

I'm yet to test it out further, but for now it seems to have fixed my basic issue of the 403 Forbidden Error.

I'll post back soon if I encounter any more problems.

Cheers.

Share this post


Link to post
Share on other sites

Now I have run into a bit of a problem.

Both websites are working and accessible, however I want to clean things up for aesthetics and also for Search-Engine reasons... I want the websites to appear totally independent of each other.

I set up a 301 Redirect in my cPanel so that www.secondwebsite.example.com redirects to www.secondwebsite.com - This works perfectly.

- the code for this is added to the .htaccess file in public_html/site-secondwebsite.com

I also set up a 301 Redirect in cPanel so that www.example.com/site-secondwebsite.com redirects to www.secondwebsite.com - This does NOT work :(

- the code for this is added to the bottom of the ProcessWire .htaccess in public_html/

Does anyone have a solution? Once I fix this last issue, I'm good to go!

Any help would be much appreciated.

Thanks.

Share this post


Link to post
Share on other sites

have you tried to set it to the top of the htaccess file?

Share this post


Link to post
Share on other sites

... ... ...

I also set up a 301 Redirect in cPanel so that www.example.com/site-secondwebsite.com redirects to www.secondwebsite.com - This does NOT work :(

- the code for this is added to the bottom of the ProcessWire .htaccess in public_html/

... ... ...

I must say I cannot really follow what you have setup, but If you have to do a redirect for a whole site / domain, I'm pretty sure you cannot do it _after_ all PW-instructions in the htaccess. Instead you need to put it at first and the PW-stuff after it.

BTW: to say "This does not work" is less helpfull for people who want try to help. For example: a detailed description of what you get when requesting a URL that should redirected would be much better.

Share this post


Link to post
Share on other sites
If I understand the problem correcty, the easiest solution is to organize your folder a little bit different. I would suggest that you keep each site in its own subfolder, so your public_html folder contains only some folders, but no .htaccess or similar. This way you avoid that your public_html/.htaccess rules are inherited by your other domains/sites. Use these subfolder as your document root in cPanel.

public_html/example.com/  

public_html/secondwebsite.com/
  • Like 1

Share this post


Link to post
Share on other sites

I use CPanel with several servers and I have never had this problem.

I normally have a site in the public_html folder and then one or more add-on sites in public_html/mysite.com/ folders. Some of these are true add-ons and others are sub-domains.

I must admit, I never have any redirects though.

Share this post


Link to post
Share on other sites

I must say I cannot really follow what you have setup, but If you have to do a redirect for a whole site / domain, I'm pretty sure you cannot do it _after_ all PW-instructions in the htaccess. Instead you need to put it at first and the PW-stuff after it.

BTW: to say "This does not work" is less helpfull for people you want try to help. For example: a detailed description of what you get when requesting a URL that should redirected would be much better.

I apologise horst. I'll try to explain this better, using real examples:

www.streetboarding.org - (Main Website) - This is the ProcessWire site, located in the public_html directory.

>>> www.streetboards.com.au - (Add-On domain) - This is my second website, located in the public_html/site-streetboards.com.au directory.

Both of those are accessible by their respective URL's. That's cool. No more 403 Errors.

I hope I've explained it a bit better now?

Any help is greatly appreciated. Happy to attach the .htaccess files if that assists?

If I understand the problem correcty, the easiest solution is to

organize your folder a little bit different. I would suggest that you

keep each site in its own subfolder, so your public_html folder contains

only some folders, but no .htaccess or similar. This way you avoid that

your public_html/.htaccess rules are inherited by your other

domains/sites. Use these subfolder as your document root in cPanel.

 
public_html/example.com/  
public_html/secondwebsite.com/

I suppose your method would make it much more organised.

One question though - Would I need to set-up a 301 Redirect on my root public_html to the index.html file in the subfolder for my main site? If so, then my above problem is still relevent... as I would be left with the problem of www.example.com/example.com still showing...?

I use CPanel with several servers and I have never had this problem.

I normally have a site in the public_html folder and then one or more

add-on sites in public_html/mysite.com/ folders. Some of these are true

add-ons and others are sub-domains.

I must admit, I never have any redirects though.

Hi Joss, have you tried with your add-on sites browsing to those subfolders from your main sites URL? I mean, if you haven't set-up redirects then what's to stop people (and search engines) navigating to them?

Share this post


Link to post
Share on other sites
Hi Joss, have you tried with your add-on sites browsing to those subfolders from your main sites URL? I mean, if you haven't set-up redirects then what's to stop people (and search engines) navigating to them?

Well, there is no link from anywhere to the sub folder mysite.com/myaddon.com, so how would they find them in the first place to browse to them?

The zone records only point to the domain name myaddon.com and the records in apache direct that request directly to the correct folder.

So, I don't see why a redirect would be needed.

Browsing to the subfolder via the parent folder would break a lot of systems simply because they would reference the wrong "root" for that particular domain - but that is not an issue because that path is not publicly recognised. 

Share this post


Link to post
Share on other sites

One question though - Would I need to set-up a 301 Redirect on my root public_html to the index.html file in the subfolder for my main site? If so, then my above problem is still relevent... as I would be left with the problem of www.example.com/example.com still showing...?

If you can change the document_root for each of your domains the should be no need to redirect. None of your domains should have the public_html folder as a document_root. Maybe this cpanel forum thread helps in setting up the document roots: http://forums.cpanel.net/f34/how-change-primary-domain-landing-folder-227531.html
  • Like 1

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 EyeDentify
      Hello Dear PW Gurus.

      Hope you fair well in these Corona Crisis times.

      Anyhow, i have a problem with a Cryptic error message that shows up when i am trying to Delete images out of a Images field.
      The Error message does say a little but it does not make sense to me why i can´t delete the images because of it.

      Is it some permission issue perhaps?

      I will attach screenshots of it and what i did prior to it.
      I am from sweden so ignore the funny words here and there.

      Hope you all can send me on the right track.
      i am running PW 3.0.139 on this install.

      Step1:

      Step 2: Select the images with the trashcan symbol

       
      Step 3: Cryptic Error message

      I am scratching my head on this one, have not seen this before.

      Thankfull for all help.
      /EyeDentify
    • By abdulqayyum
      Hy Processwire community,
      There are some problem in fileCompiler cache.
      when i change under the directory \site\templates\ it must change under the directory /site/assets/cache/FileCompiler/site/templates/
      but it does not update and functionality working with /site/assets/cache/FileCompiler/site/templates/ directory.
       
      In this case please suggest me how i clear fileCompiler cache?
      what i have to clear it manually?
      Thanks AbdulQayyum.
    • By gebeer
      Although the PW backend is really intuitive, ever so often my clients need some assistance. Be it they are not so tech savvy or they are not working in the backend often.
      For those cases it is nice to make some help videos available to editors. This is what this module does.
      ProcessHelpVideos Module
      A Process module to display help videos for the ProcessWire CMS. It can be used to make help videos (screencasts) available to content editors.
      This module adds a 'Help Videos" section to the ProcessWire backend. The help videos are accessible through an automatically created page in the Admin page tree. You can add your help videos as pages in the page tree. The module adds a hidden page to the page tree that acts as parent page for the help video pages. All necessary fields and templates will be installed automatically. If there are already a CKEditor field and/or a file field for mp4 files installed in the system, the module will use those. Otherwise it will create the necessary fields. Also the necessary templates for the parent help videos page and it's children are created on module install. The module installs a permission process-helpvideos. Every user role that should have access to the help video section, needs this permission. I use the help video approach on quite a few production sites. It is stable so far and well received by site owners/editors. Up until now I installed required fields, templates and pages manually and then added the module. Now I added all this logic to the install method of the module and it should be ready to share.
      The module and further description on how to use it is available on github: https://github.com/gebeer/ProcessHelpVideos
      If you like to give it a try, I am happy to receive your comments/suggestions here.
    • By abdulqayyum
      Hy everyone,
      i am using loginRegister module for front-end user login.
      In this module user can login with Email/username, i am showing with Email. done
      but not showing Email in Forgotton Password section. there still showing with username.

      i want to show Forgotton Password with Email instead username. and should reset with email.

      please help me in this section, how i can set it with Email.

      Thanks AbdulQayyum.
    • By abdulqayyum
      Markup-Google-Recaptcha is not working with LoginRegister module in Forgotton Password Form.
      Here is my code
      wire-> modules -> process -> ProcessForgotPassword.php
      protected function step1_renderForm() {
              $form = $this->modules->get("InputfieldForm");
              $form->attr('action', './?forgot=1');
              $form->attr('method', 'post');
          
              $field = $this->modules->get("InputfieldText");     
              $field->attr('id+name', 'username');
              $field->attr('class', 'redesign-field forgotPassFeild');
              $field->setAttribute('placeholder', 'Username');
              $field->required = true;
              $field->label = $this->_("Forgotton Password");
              $field->description = $this->_("If you cannot remember your password to access the affiliates portal. simply provide your username in the box below and we'll send you a reset link via email.");
              $form->add($field);
               
             // Calling MarkupGoogleRecaptcha Module.
              $captcha = $modules->get("MarkupGoogleRecaptcha");
             //  rendering form with recaptcha
              $captcha->render($form);
         
              $submit = $this->modules->get("InputfieldSubmit");
              $submit->attr('id+name', 'submit_forgot');
              $form->add($submit);
              $this->session->userResetStep = 1;
               
              // rendering form
               $out .= $form->render();
          
              // getting captcha script
              $out .= $captcha->getScript();
              return $out;
          }

      I am following this one example.

      please suggest me how i can show MarkupGoogleRecaptcha in forgotton password.
      Getting log error


      Thanks,
      Abdul Qayyum
×
×
  • Create New...