Bug #14461
closedusing mod_rewrite to mask URL causes Typo3 to always display same content
0%
Description
I have installed typo3 in a subdirectory of my site, t3/site/. When visiting the URL http://maple.leph.net/t3/site/software.18.0.html (for example), everything works fine. Using htaccess and mod_rewrite, I wanted to allow users to enter in http://maple.leph.net/software.18.0.html (removing t3/site/ from the URL). However, when I did this, though the correct URL displayed in the address bar, typo3 would always simply serve up the home page content, and nothing else.
I tracked the problem down to the getIndpEnv function in the t3lib/class.t3lib_div.php file. By modifying line 2631 to use REQUEST_URI instead of SCRIPT_NAME I was able to make Typo3 respond as I expected. Without the change, Typo3 was returning the full path to my page, thus including t3/site/ in the URL. By using REQUEST_URI instead, Typo3 used the called path, which has t3/site/ removed.
Here’s the actual change made, original line commented out:
case 'TYPO3_REQUEST_DIR':
## Modified the below line to use REQUEST_URI instead of SCRIPT_NAME, so that I could use .htaccess to do site masking
##return t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')).'/';
return t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST').t3lib_div::dirname(t3lib_div::getIndpEnv('REQUEST_URI')).'/';
break;
I have two .htaccess files, one in my htdocs directory and the other in my htdocs/t3/site directory. simulateStaticDocuments is set to 1. The .htaccess in my htdocs directory contains the following:
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} .*maple.leph.net
RewriteCond %{REQUEST_URI} !t3/site/.*
RewriteCond %{REQUEST_URI} !devel/
RewriteCond %{REQUEST_URI} !b2
RewriteCond %{REQUEST_URI} !gallery
RewriteRule ^(.*)$ t3/site/$1 [L]
My .htaccess file in the htdocs/t3/site directory contains the following:
- Enable URL rewriting
RewriteEngine On
RewriteRule ^(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)/ - [L]
RewriteRule ^typo3$ typo3/index_re.php [L]
- If the file/symlink/directory does not exist => Redirect to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
- Main URL rewriting.
RewriteRule ^[^/]*\.html$ index.php [L]
My hosting provider is running Apache (not sure of version) on FreeBSD.
PHP is version 4.3.10
MySQL is version 4.0.18-log
(issue imported from #M631)