From 9d48ee446b10e492b83448c3778b48729839b788 Mon Sep 17 00:00:00 2001 From: David King Date: Mon, 2 Sep 2013 09:43:41 -0700 Subject: [PATCH] [ticket/11215] Add commented-out URL rewrite capability to .htaccess PHPBB3-11215 --- phpBB/.htaccess | 30 ++++++++++++++++++++++++++---- phpBB/includes/functions.php | 8 ++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/phpBB/.htaccess b/phpBB/.htaccess index 474f9774c2..df17b17d7d 100644 --- a/phpBB/.htaccess +++ b/phpBB/.htaccess @@ -1,12 +1,34 @@ + +# +# Uncomment the following line if you will be using any of the URL +# rewriting below. +# +#RewriteEngine on + # # Uncomment the statement below if you want to make use of # HTTP authentication and it does not already work. # This could be required if you are for example using PHP via Apache CGI. # -# -#RewriteEngine on #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] -# + +# +# Uncomment the following 3 lines if you want to rewrite URLs passed through +# the front controller to not use app.php in the actual URL. In other words, +# a controller is by default accessed at /app.php/my/controller, but will then +# be accessible at either /app.php/my/controller or just /my/controller +# +#RewriteCond %{REQUEST_FILENAME} !-f +#RewriteCond %{REQUEST_FILENAME} !-d +#RewriteRule ^(.*)$ app.php [QSA,L] + +# +# If symbolic links are not already being followed, +# uncomment the line below. +# http://anothersysadmin.wordpress.com/2008/06/10/mod_rewrite-forbidden-403-with-apache-228/ +# +#Options +FollowSymLinks + Order Allow,Deny @@ -16,4 +38,4 @@ Deny from All Order Allow,Deny Deny from All - + \ No newline at end of file diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d85606944f..4d2d704a43 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -5747,6 +5747,14 @@ function phpbb_get_web_root_path(Request $symfony_request, $phpbb_root_path = '' } $corrections = substr_count($path_info, '/'); + + // When URL Rewriting is enabled, app.php is optional. We have to + // correct for it not being there + if (strpos($symfony_request->getRequestUri(), $symfony_request->getScriptName()) === false) + { + $corrections -= 1; + } + $path = $phpbb_root_path . str_repeat('../', $corrections); return $path; }