|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-04-02 21:26 UTC] edwardzyang at thewritingpot dot com
Description:
------------
Livedocs's htaccess file works in a very strange way, by rewriting to a non-existent file, letting Apache's error document forward it to index.php, and then handling it. This is confusing, and doesn't work in certain cases (in said cases, the user consistently gets the File protocols and wrappers page). A better htaccess file:
Index: .htaccess.in
===================================================================
RCS file: /repository/livedocs/.htaccess.in,v
retrieving revision 1.3
diff -u -r1.3 .htaccess.in
--- .htaccess.in 4 Oct 2004 06:41:13 -0000 1.3
+++ .htaccess.in 2 Apr 2007 21:16:59 -0000
@@ -1,6 +1,6 @@
RewriteEngine on
-RewriteRule @WEBBASE@.*\.[^h][^t][^m][^l]$ @WEBBASE@$1.html
-ErrorDocument 404 @WEBBASE@index.php
+RewriteCond %{REQUEST_FILENAME} !-f [OR]
+RewriteCond %{QUERY_STRING} purge=1
+RewriteRule ^([A-Za-z_]+)/([A-Za-z._-]+)\.html$ @WEBBASE@index.php?l=$1&q=$2 [L,QSA]
DirectoryIndex index.php
php_value default_charset "UTF-8"
AddCharset UTF-8 .html
In this case, we specifically match the HTML file, and directly refer to the index.php script, instantiating the correct l and q parameters. A user can also pass ?purge=1 to the HTML file to force it to be regenerated, and the system intelligently detects when the file does not exist using the -f command.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 00:00:01 2025 UTC |
Here is an updated patch that takes into account the fact that some functions/extensions have numbers in their names. Index: .htaccess.in =================================================================== RCS file: /repository/livedocs/.htaccess.in,v retrieving revision 1.3 diff -u -r1.3 .htaccess.in --- .htaccess.in 4 Oct 2004 06:41:13 -0000 1.3 +++ .htaccess.in 4 Apr 2007 01:02:09 -0000 @@ -1,6 +1,6 @@ RewriteEngine on -RewriteRule @WEBBASE@.*\.[^h][^t][^m][^l]$ @WEBBASE@$1.html -ErrorDocument 404 @WEBBASE@index.php +RewriteCond %{REQUEST_FILENAME} !-f [OR] +RewriteCond %{QUERY_STRING} purge=1 +RewriteRule ^([A-Za-z0-9_]+)/([A-Za-z0-9._-]+)\.html$ @WEBBASE@index.php?l=$1&q=$2 [L,QSA] DirectoryIndex index.php -php_value default_charset "UTF-8" AddCharset UTF-8 .html I suspect that IDREG in livedocs/common.php needs to be updated too, but it has no noticeable effect on things right now.