ohthanks Posted September 17, 2014 Share Posted September 17, 2014 I've been building out a website design that has used "site" as a page name and my install was throwing 403 errors loading the page. I would really prefer to not change the url-slug so I have renamed the site directory and edited the root index.php $siteDir variable to reflect the new site directory location. Seems to work fine, am I missing anything that will cause problems with the install? Is there an easier way to accomplish this? I tried finding the cause of the 403 in the default .htaccess file with no luck. Is proccesswire internally checking to see if the current url matches the $siteDir and throwing the error? Thanks! Link to comment Share on other sites More sharing options...
OrganizedFellow Posted September 17, 2014 Share Posted September 17, 2014 Interesting error! I have no solution, but I'd like to see what the #HotShots have to say about this. Link to comment Share on other sites More sharing options...
sforsman Posted September 17, 2014 Share Posted September 17, 2014 (edited) You shouldn't edit index.php directly. Instead you should create a file called index.config.php and put the following there. <?php if(!defined("PROCESSWIRE")) die(); function ProcessWireHostSiteConfig() { return ["*"=>"myNewSiteLocation"]; } Obviously change the string myNewSiteLocation. Edit: Forgot to mention that if your directory name doesn't start with "site-", you should create your own .htaccess inside your site-directory that protects assets in the same way the main .htaccess does. The main .htaccess protects only the default site folder and folders starting with "site-". You could modify the main .htaccess too, but again you should avoid editing it to make upgrading PW easier. Edited September 17, 2014 by sforsman 2 Link to comment Share on other sites More sharing options...
LostKobrakai Posted September 17, 2014 Share Posted September 17, 2014 The 403 error is to prevent misbehavior. The .htaccess file lets all requests to existing files on the disk directly though without bothering php / processwire with it. So if you could name a page "site" (child of home) you would mimic the path of the real folder structure and with bad luck you would expose some of the files there. Also if that happens, it's most likely not the content you would want there, as it's just the file, not the page you would like to see, as the request doesn't even get to be parsed by php. Link to comment Share on other sites More sharing options...
ohthanks Posted September 17, 2014 Author Share Posted September 17, 2014 Yep, it completely makes sense to throw the 403, I was thinking through the down sides of just allowing a page named "site" to co-exist with the the default site directory and and it seemed liked it would potentially cause a lot of issues for exactly the reasons you stated. The index.config.php solution seems to have worked great. Thanks guys! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now