Home > other >  How to make viewforum.php?foo=bar request serve a file instead of a PHP code?
How to make viewforum.php?foo=bar request serve a file instead of a PHP code?

Time:12-06

I'm archiving a phpBB forum into flat HTML files, without any PHP code anymore. I used wget (see enter image description here

How to make Apache serve example.com/forum/viewforum.php?f=2&start=25 as a file, and not as a request to viewforum.php with a query string? The latter does not work obviously and gives a 404.

I already tried this htaccess with no success:

RemoveHandler .php .phtml .php3
RemoveType .php .phtml .php3
php_flag engine off

Note: this is how I archived the forum:

wget -m -p -np -R "*sid=*,ucp.php*,memberlist.php*,*mode=viewprofile*,*view=print*,viewonline.php*,search.php*,posting.php*" https://forums.example.com

CodePudding user response:

Interesting problem indeed! force me to dig many Apache docs. In the end solution was simple i.e. to escape ? so that Apache doesn't treat ? and part after that as query string.

You may use this rewrite rule in your site root .htaccess:

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/forum/viewforum\.php$ [NC]
RewriteCond %{QUERY_STRING} .
RewriteRule ^ %{REQUEST_URI}\?%{QUERY_STRING} [L,NC]

PS: \? is escaped ? so make Apache load /forum/viewforum.php?f=2&start=25 as a file.

  • Related