Project

General

Profile

Actions

Bug #14461

closed

using mod_rewrite to mask URL causes Typo3 to always display same content

Added by old_slsmukai over 19 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Assignee:
Category:
Frontend
Target version:
-
Start date:
2004-12-21
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
3.7.0
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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:

  1. Enable URL rewriting
    RewriteEngine On
    RewriteRule ^(typo3|typo3temp|typo3conf|t3lib|tslib|fileadmin|uploads|showpic\.php)/ - [L]
    RewriteRule ^typo3$ typo3/index_re.php [L]
  1. If the file/symlink/directory does not exist => Redirect to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
  1. 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)

Actions #1

Updated by old_slsmukai over 19 years ago

forgot to add 'root cause'. Essentially what was happening (without change), was that Typo3 was calculating the length of the script name as being too long. It was using this length to create a substring from some other request string, and was ending up with just a plain "/" instead of, say, "/28.0.html". With just a plain "/", I was always getting shown index.php with the home page content.

Actions #2

Updated by Sebastian Kurfuerst about 19 years ago

Did I get this correctly that this problem is solved now?

Actions #3

Updated by Ingo Renner almost 16 years ago

could not be reproduced during Bug Day 07/2008

Actions #4

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF