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

×
×
  • Create New...