diff options
author | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-10 22:03:20 +0000 |
---|---|---|
committer | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2011-03-10 22:03:20 +0000 |
commit | 4361dc15a79480675b055d6c3baad593adb8343b (patch) | |
tree | a17ee49753b1096f45fde9663341ed8f920b47c5 | |
parent | 9925507bbe4465772e246daa24009e463422211b (diff) | |
download | elgg-4361dc15a79480675b055d6c3baad593adb8343b.tar.gz elgg-4361dc15a79480675b055d6c3baad593adb8343b.tar.bz2 |
Refs #2228: Deprecated use of pg/ in page handlers. Now we get to have nice clean urls like "example.com/bookmarks"
git-svn-id: http://code.elgg.org/elgg/trunk@8651 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/handlers/page_handler.php | 21 | ||||
-rw-r--r-- | htaccess_dist | 20 |
2 files changed, 36 insertions, 5 deletions
diff --git a/engine/handlers/page_handler.php b/engine/handlers/page_handler.php index c71e820b2..bfdb0cee3 100644 --- a/engine/handlers/page_handler.php +++ b/engine/handlers/page_handler.php @@ -3,9 +3,21 @@ * Pages handler. * * This file dispatches pages. It is called via a URL rewrite in .htaccess - * from http://site/pg/handler/page1/page2. The first element after 'pg/' is + * from http://site/handler/page1/page2. The first element after site/ is * the page handler name as registered by {@link elgg_register_page_handler()}. * The rest of the string is sent to {@link page_handler()}. + * + * Note that the following handler names are reserved by elgg and should not be + * registered by any plugins: + * * action + * * cache + * * services + * * export + * * mt + * * xml-rpc.php + * * rewrite.php + * * tag (deprecated, reserved for backwards compatibility) + * * pg (deprecated, reserved for backwards compatibility) * * {@link page_handler()} explodes the pages string by / and sends it to * the page handler function as registered by {@link elgg_register_page_handler()}. @@ -18,6 +30,13 @@ require_once(dirname(dirname(__FILE__)) . "/start.php"); +$url = current_page_url(); +$new_url = preg_replace('#/pg/#', '/', $url); +if ($url !== $new_url) { + header("HTTP/1.1 301 Moved Permanently"); + header("Location: $new_url"); +} + $handler = get_input('handler'); $page = get_input('page'); diff --git a/htaccess_dist b/htaccess_dist index 4508c539b..c2f144575 100644 --- a/htaccess_dist +++ b/htaccess_dist @@ -97,10 +97,13 @@ RewriteEngine on # #RewriteBase / -RewriteRule ^action\/([A-Za-z0-9\_\-\/]+)$ engine/handlers/action_handler.php?action=$1&%{QUERY_STRING} - -RewriteRule ^pg\/([A-Za-z0-9\_\-]+)\/(.*)$ engine/handlers/page_handler.php?handler=$1&page=$2&%{QUERY_STRING} +# In for backwards compatibility RewriteRule ^pg\/([A-Za-z0-9\_\-]+)$ engine/handlers/page_handler.php?handler=$1&%{QUERY_STRING} +RewriteRule ^pg\/([A-Za-z0-9\_\-]+)\/(.*)$ engine/handlers/page_handler.php?handler=$1&page=$2&%{QUERY_STRING} +RewriteRule ^tag\/(.+)\/?$ engine/handlers/page_handler.php?handler=search&page=$1 + + +RewriteRule ^action\/([A-Za-z0-9\_\-\/]+)$ engine/handlers/action_handler.php?action=$1&%{QUERY_STRING} RewriteRule ^cache\/(.*)$ engine/handlers/cache_handler.php?request=$1&%{QUERY_STRING} @@ -112,9 +115,18 @@ RewriteRule ^export\/([A-Za-z]+)\/([0-9]+)\/([A-Za-z]+)\/([A-Za-z0-9\_]+)\/$ eng RewriteRule xml-rpc.php engine/handlers/xml-rpc_handler.php RewriteRule mt/mt-xmlrpc.cgi engine/handlers/xml-rpc_handler.php -RewriteRule ^tag/(.+)/?$ engine/handlers/page_handler.php?handler=search&page=$1 # rule for rewrite module test during install - can be removed after installation RewriteRule ^rewrite.php$ install.php +# Everything else that isn't a file gets routed through the page handler +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^([A-Za-z0-9\_\-]+)$ engine/handlers/page_handler.php?handler=$1 [QSA] + +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^([A-Za-z0-9\_\-]+)\/(.*)$ engine/handlers/page_handler.php?handler=$1&page=$2 [QSA] + + </IfModule> |