Skip to content
Permalink
Browse files

Allow URLs to be rewritten to server root using external .htaccess

For example, with the following directory structure, Bludit is
installed in its own subdirectory:

web_root
├── .htaccess
└── bludit
    ├── bl_content
    ├── bl_kernel
    │    ...
    ├── .htaccess
    ├── index.php
    └── install.php

However, it may be desired that Bludit's URLs are based from the web
root, not /bludit:

Good:	http://example.com/about
Bad: 	http://example.com/bludit/about

The config file web_root/.htaccess includes the following rule to
rewrite requests to web_root/bludit:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) bludit/$1 [NC,L,QSA]

When a page is accessed, Bludit finds that the URL /about doesn't
match the script path bludit/index.php, and assumes that the site's
root should therefore be "/".
  • Loading branch information...
JonathanHolvey committed Aug 26, 2017
1 parent d17550c commit d8a73e7951f2408c6ac1fc79b7540be0b71f25b6
Showing with 12 additions and 4 deletions.
  1. +6 −2 bl-kernel/boot/init.php
  2. +6 −2 install.php
@@ -209,12 +209,16 @@
$base = dirname($base);
}
if($base!=DS) {
// Assume URLs are rewritten to server root if current URL doesn't start with $base
if (strpos($_SERVER['REQUEST_URI'], $base) !== 0) {
$base = '/';
}
if($base!=DS and strlen($base > 0)) {
$base = trim($base, '/');
$base = '/'.$base.'/';
}
else {
// Workaround for Windows Web Servers
$base = '/';
}
@@ -84,12 +84,16 @@
$base = dirname($base);
}
if($base!=DS) {
// Assume URLs are rewritten to server root if current URL doesn't start with $base
if (strpos($_SERVER['REQUEST_URI'], $base) !== 0) {
$base = '/';
}
if($base!=DS and strlen($base > 0)) {
$base = trim($base, '/');
$base = '/'.$base.'/';
}
else {
// Workaround for Windows Web Servers
$base = '/';
}

0 comments on commit d8a73e7

Please sign in to comment.
You can’t perform that action at this time.