Add pretty URL support
This commit is contained in:
parent
a038bde743
commit
a94df59ac5
@ -59,7 +59,11 @@ function get_page_clean_url($echo = true, $slug = null) {
|
|||||||
if ($slug == null) {
|
if ($slug == null) {
|
||||||
$slug = get_page_slug(false);
|
$slug = get_page_slug(false);
|
||||||
}
|
}
|
||||||
$url = formatsiteurl(get_site_url(false)) . "index.php?id=$slug";
|
if (PRETTY_URLS) {
|
||||||
|
$url = formatsiteurl(get_site_url(false)) . "$slug";
|
||||||
|
} else {
|
||||||
|
$url = formatsiteurl(get_site_url(false)) . "index.php?id=$slug";
|
||||||
|
}
|
||||||
if ($echo) {
|
if ($echo) {
|
||||||
echo $url;
|
echo $url;
|
||||||
} else {
|
} else {
|
||||||
@ -91,7 +95,15 @@ function get_page_url($echo = true, $slug = null) {
|
|||||||
if (isset($_GET['siteid'])) {
|
if (isset($_GET['siteid'])) {
|
||||||
$siteid = "&siteid=" . preg_replace("/[^0-9]/", '', $_GET['siteid']);
|
$siteid = "&siteid=" . preg_replace("/[^0-9]/", '', $_GET['siteid']);
|
||||||
}
|
}
|
||||||
$url = formatsiteurl(get_site_url(false)) . "index.php?id=$slug$edit$theme$template$color$siteid";
|
$args = "$edit$theme$template$color$siteid";
|
||||||
|
if (PRETTY_URLS) {
|
||||||
|
if ($args != "") {
|
||||||
|
$args = "?$args";
|
||||||
|
}
|
||||||
|
$url = formatsiteurl(get_site_url(false)) . "$slug$args";
|
||||||
|
} else {
|
||||||
|
$url = formatsiteurl(get_site_url(false)) . "index.php?id=$slug$args";
|
||||||
|
}
|
||||||
if ($echo) {
|
if ($echo) {
|
||||||
echo $url;
|
echo $url;
|
||||||
} else {
|
} else {
|
||||||
|
@ -37,6 +37,9 @@ define('URL', '/sitewriter');
|
|||||||
// Folder for public files
|
// Folder for public files
|
||||||
define('FILE_UPLOAD_PATH', __DIR__ . '/public/files');
|
define('FILE_UPLOAD_PATH', __DIR__ . '/public/files');
|
||||||
|
|
||||||
|
// Use pretty URLs (requires correct web server configuration)
|
||||||
|
define('PRETTY_URLS', false);
|
||||||
|
|
||||||
// Location of MaxMind GeoIP database
|
// Location of MaxMind GeoIP database
|
||||||
//
|
//
|
||||||
// I'll just leave this here:
|
// I'll just leave this here:
|
||||||
|
@ -1,9 +1,21 @@
|
|||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
RewriteBase /
|
RewriteBase /
|
||||||
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-d [OR]
|
|
||||||
RewriteCond %{REQUEST_URI} ^/$
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-l
|
|
||||||
|
|
||||||
RewriteRule (.*) /sitewriter/public/$1 [L]
|
# Everything else
|
||||||
|
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
||||||
|
RewriteCond %{REQUEST_FILENAME} -d
|
||||||
|
RewriteRule ^(.+) - [PT,L]
|
||||||
|
|
||||||
|
# Webroot
|
||||||
|
RewriteRule ^/$ /sitewriter/public [L]
|
||||||
|
|
||||||
|
# Other URLs (assets, etc)
|
||||||
|
RewriteCond %{DOCUMENT_ROOT}/sitewriter/public%{REQUEST_URI} -d [OR]
|
||||||
|
RewriteCond %{DOCUMENT_ROOT}/sitewriter/public%{REQUEST_URI} -f
|
||||||
|
RewriteRule ^(.*)$ /sitewriter/public/$1 [L]
|
||||||
|
|
||||||
|
# Pretty URLs
|
||||||
|
RewriteCond %{DOCUMENT_ROOT}/sitewriter/public%{REQUEST_URI} !-d [OR]
|
||||||
|
RewriteCond %{DOCUMENT_ROOT}/sitewriter/public%{REQUEST_URI} !-f
|
||||||
|
RewriteRule ^(.*)$ /sitewriter/public/index.php?id=$1 [L,QSA]
|
Loading…
x
Reference in New Issue
Block a user