[Typo3] Realurl problem resolution

Ian Foulds IanFoulds at x-act.co.uk
Fri Sep 9 16:38:08 CEST 2005


Hi Folks

I've been pulling out what little hair I have left trying to solve the problem with Realurl and the decoding of paths not working correctly when Rewrite is configured in httpd.conf.

Doing some debugging in index.php and the realurl code showed that pages in a subfolder were never found within the list of pages retuned from the SQL query. The query root page was incirrectly being set to the root page of the site and not the page indicated in the site subfolder.

As an example, www.mysite.co.uk/page1/page20/viewthispage.html should cause Realurl to look at sub pages of 'page20' and find 'viewthispage.html'. However, when trying to locate the page id for 'page20', t3lib_div always returned the page id of the site root page. Therefore Realurl could not locate the page it was looking for.

It transpires that the $_SERVER['SCRIPT_NAME'] was wrong. According to the Apache documentation this should be the URL of the script being processed, what it actually contained was the URL of the requested page, in the case above 'page1/page20/viewthispage.html'. What it should have been was 'index.php'. Clearly mod_rewrite was not doing what it was supposed to do. Tests proved that this was not a problem restricted to Typo3 or Realurl but occurred whenever a similar set of rewrite rules where used.

I spent many hours trawling the web for a resolution to this without much luck. I did however find an article that mentioned using the PT flag on the RewriteRule so I tried it and bingo - Realurl now works. Tested on both Linux and Windows with success on both platforms.

My httpd.conf now looks like this:

    RewriteEngine On
    RewriteRule ^/typo3$ - [L]
    RewriteRule ^/typo3/.*$ - [L]
    RewriteRule ^/typo3conf$ - [L]
    RewriteRule ^/typo3conf/.*$ - [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

    RewriteRule (\.html|/)$ /index.php [PT]

N.B. Notice the [PT] appended to the last line - this is the bit of magic to solve your woes!!.

Regards

 

Ian Foulds
www.x-act.co.uk    tel: 01629 825092




More information about the TYPO3-english mailing list