]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2228: Deprecated use of pg/ in page handlers. Now we get to have nice clean...
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 10 Mar 2011 22:03:20 +0000 (22:03 +0000)
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>
Thu, 10 Mar 2011 22:03:20 +0000 (22:03 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8651 36083f99-b078-4883-b0ff-0f9b5a30f544

engine/handlers/page_handler.php
htaccess_dist

index c71e820b2ad6248d1d84d6ce7e5f5d57c623c3e1..bfdb0cee3480b122a538cbc9c2ec4c1da2e4a1bb 100644 (file)
@@ -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()}.
 
 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');
 
index 4508c539bf3f2faf469347c632616eaad1deed66..c2f1445750b0be4fa55e4b97999d53387e0c0ecb 100644 (file)
@@ -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>