Jump to content

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


4ldesigns
 Share

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

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

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

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

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

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

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

Link to comment
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
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 JeevanisM
      Hi,
      I have installed 1 year old project backup into the new latest PW version. I used an earlier backup(taken in August 2020) and installed such as :
      1. I downloaded the latest (ProcessWire 3.0.185 dev © 2021) then extracted into htdocs 2. copy pasted the site-profile from my backup. (this has the files/folders same as other site profiles, classic, beginner etc) 3. I chose my backup site profile and installed 4. I am able to login the admin panel  5. My fronted home page shows error as below  Error: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'page_path_history.language_id' in 'field list' (in wire/modules/PagePathHistory.module line 752) #0 wire/modules/PagePathHistory.module (752): PDOStatement->execute() #1 wire/core/PagesPathFinder.php (1014): PagePathHistory->getPathInfo('/', Array) #2 wire/core/PagesPathFinder.php (222): PagesPathFinder->getPathHistory('/') #3 wire/core/PagesRequest.php (255): PagesPathFinder->get('/', Array) #4 wire/core/Wire.php (414): PagesRequest->___getPage() #5 wire/core/WireHooks.php (951): Wire->_callMethod('___getPage', Array) #6 wire/core/Wire.php (485): WireHooks->runHooks(Object(PagesRequest), 'getPage', Array) #7 wire/modules/Process/ProcessPageView.module (10 This error message was shown because: you are logged in as a Superuser. Error has been logged.
       
      so I removed the line where its selecting language_id from the file wire/modules/PagePathHistory.module line 752
      But this is an ugly fix, so is there any other proper fix for this issue ? Does any one experience same issue when trying to install from a backup site profile ? 

       

       
       thanks
       
    • By theExo
      Hey folks,
      im pretty new to Processwire. A client of mine asked me to migrate his old (v2.5) Processwire Website. On his server its running on PHP 5.3 and i want to upgrade + migrate the site at the same time. I Downloaded the Site from his server to set it up locally, replaced the /wire directory, index.php and .htaccess with the files of the latest version. After that i changed the DB Connection details in the config.php, swapped to PHP 7.4 and now, when i open up the site on my localhost i get this error:
      compile(\ProcessWire\wire("config")->paths->root . "site/templates/includes/head.inc.php",array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true)))?> compile(\ProcessWire\wire("config")->paths->root . "site/templates/includes/header.inc.php",array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true)))?> compile(\ProcessWire\wire("config")->paths->root . "site/templates/includes/start_content.inc.php",array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true)))?> compile(\ProcessWire\wire("config")->paths->root . "site/templates/includes/footer.inc.php",array('includes'=>true,'namespace'=>true,'modules'=>true,'skipIfNamespace'=>true)))?> The page itself doesnt load, just a white space with this stuff on it
      I checked if the files exist, they do.
      I hope anyone can help me with that 🙂 Thanks in advance!
    • By spercy16
      I was hoping to be able to do this entirely in PHP but was having all kind of issues getting it to see my values as numbers instead of strings (got error messages because my PW debugging is currently set to true). I currently have about 10 cards that PW is generating that include thumbnails, descriptions, donation amounts (raised amounts and goal amounts), and donate buttons. What I was trying to do was take the goal amount divide it by the raised amount (using PHP) and simply insert that value into the Progress element's Value attribute. Sounded simple enough but I couldn't get PHP to simply divide those two fields. First I tried dividing the goal value by the raised value and inserting it into the value attribute, like so:
      <? php $raised = $page->get("raisedAmount$count"); $goal = $page->get("goalAmount$count"); $percent = $goalNum / $raisedNum; ?> <progress value="<?php echo $percent; ?>" max="100"></progress> Which gave me this error message:
      Uncaught TypeError: Unsupported operand types: string / string
      Then I tried converting the two strings to integers because apparently PHP couldn't detect they were numbers and do it, like so:
      <?php $raised = $page->get("raisedAmount$count"); $goal = $page->get("goalAmount$count"); $goalNum = (int) $goal; $raisedNum = (int) $raised; if ($raisedNum != 0) : $percent = $goalNum / $raisedNum; else: $percent = 0; endif; ?> <progress value="<?php echo $percent; ?>" max="100"></progress> but all of the progress bars remain at zero percent (not shown), even when I have values in some of the $raised variables.
      Please note, if I add this code:
      <?php echo $percent; ?> below the Progress element, it shows 0 on every single card, so the $percent is never calculated (as per the $percent = $goalNum / $raisedNum;) even though $raisedNum should not equal 0 during that iteration of the loop (the original code includes a loop, which I omitted to keep the code sections above smaller, notice the $count at the end of the $raised and $goal variable declarations). When the loop goes over "raisedAmount1" there is a value in there; however, after typecasting it to an integer ($raisedNum) the value is 0 for someodd reason instead of 40,000, which is what is in the $raisedAmount1 field in Processwire...
      I'm new to relatively new to PHP and Processwire and could really use some help on this one. Thanks in advance for any helpful replies!
    • By OrinTerry
      Hello everyone. I am running a small technology blog, which is in WordPress. The main problem with my blog is that it does not open on any Windows 7 computer normally. I know Windows 7 has lost official support from Microsoft but still, there are plenty of users who still use Windows 7. The blog site is already 'HTTPS' protected but after opening in any browser, it shows 'not protected' next to the URL box. So, if I migrate all the site data to 'ProcessWare', will I get the same problem here too? Any kind of feedback would be greatly appreciated.
    • By Marvin
      Hello, excuse me
      I'm new at processwire, i want to ask about a master detail system (Inheritance system) using a processwire. Can we create a Inheritance table using a processwire, and how we create it? Thank you for the help
×
×
  • Create New...