Jump to content

Renaming the default site directory


ohthanks
 Share

Recommended Posts

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

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 by sforsman
  • Like 2
Link to comment
Share on other sites

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

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

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.
×
×
  • Create New...