I have a site in a /www/
folder. In the parent directory I have an .htaccess file which passes through the /www/
directory so it is as if it does not exist.
Within that folder I have Kirby CMS as a submodule which uses it's own rewrite rules for urls. The homepage shows as http://mywebsite.local
but the links are shown as http://mywebsite.local/www/page-name
. They are dynamically generated in PHP and not hard coded.
Manually removing the /www/
from the url shows that the redirect works fine. So it must be a Kirby issue.
kirbycms
is a git submodule and I have followed this tutorial http://rimann.org/blog/kirby-git-setup.
Structure:
|- .htaccess
|- www
|- |- index.php
|- |- .htaccess
|- |- kirbycms
|- |- |- kirby
|- |- themes
|- |- |- v9
|- |- |- |- site
root .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^www/
RewriteRule ^(.*)$ www/$1 [L]
</IfModule>
kirby .htaccess:
# Kirby .htaccess
# rewrite rules
<IfModule mod_rewrite.c>
# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on
# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:
#
# RewriteBase /mysite
#
RewriteBase /
# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ error [R=301,L]
# block all files in the site folder from being accessed directly
RewriteRule ^site/(.*) error [R=301,L]
# block all files in the kirby folder from being accessed directly
RewriteRule ^kirby/(.*) error [R=301,L]
# leave robots.txt alone for search engines
RewriteRule ^robots.txt robots.txt [L]
# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]
# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
</IfModule>
# Additional recommended values
# Remove comments for those you want to use.
#
# AddDefaultCharset UTF-8
#
# php_flag short_open_tag on
index.php:
<?php
/*
---------------------------------------
Document root of your site
---------------------------------------
this should be identical with the directory
in which your index.php is located
*/
$root = dirname(__FILE__);
/*
---------------------------------------
Kirby system folder
---------------------------------------
by default this is located inside the root directory
but if you want to share one system folder for
multiple sites, you can easily change that here
and link to a shared kirby folder somewhere on your
server
*/
$rootKirby = $root . '/kirbycms/kirby';
/*
---------------------------------------
Your site folder
---------------------------------------
Your site folder contains all the site specific files
like templates and snippets. It is located in the root
directory by default, but you can move it if you want.
*/
$rootSite = $root . '/theme/v9/site';
/*
---------------------------------------
Your content folder
---------------------------------------
Your content folder is also located in the root
directory by default. You can change this here.
It can also be changed later in your site/config.php
*/
$rootContent = $root . '/content';
// Try to load Kirby
if(!file_exists($rootKirby . '/system.php')) {
die('The Kirby system could not be loaded');
}
require_once($rootKirby . '/system.php');
Does anyone know how I can set the links so they don't have the /www/
?
The solution was simple. It was a Kirby config option to have the site in a subfolder.
in
site/config/config.php
there is an option forc::set('subfolder', false);
which needs to be set to true.Then the
www
goes away.