php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40983 Livedocs htaccess is broken
Submitted: 2007-04-02 21:26 UTC Modified: 2007-08-24 14:17 UTC
From: edwardzyang at thewritingpot dot com Assigned:
Status: Wont fix Package: Livedocs problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-04 01:05 UTC] edwardzyang at thewritingpot dot com
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.
 [2007-08-24 14:17 UTC] philip@php.net
Livedocs is no longer in development, the current build system is
titled PhD.

Note: There is no such problem in PhD.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Dec 04 02:01:23 2020 UTC