[Typo3-dev] Bug in .htaccess?
Martin Poelstra
martin at beryllium.net
Thu Apr 29 12:06:54 CEST 2004
Hi all,
> I think no. The trailing slash left to the index.php rule will redirect to
> the absolute path, say http://mysite/index.php
>
> But what if your site is located in a subdirectory of this one:
> http://mysite/html/MySiteIsGreat.5.0.html
>
> Since this would be rewritten to http://mysite/index.php we would come to a
> 404 error, right?
>
> I think your first suggestion above is very right, but why doesn't this work
> on Windows machines?
I discovered that using the slash in front of index.php is depending on
the way you use the rewrite rules, i.e. in httpd.conf or in a .htaccess.
I remember correctly, I had to use the slash, because RealURL generates
paths other than just the webroot, whereas in the usual TYPO3-setups
(even with simulateStaticDocuments), you only have 'faked' HTML-pages in
the webroot.
As we're mostly talking about the .htaccess-file now, we can write the
rules for that, but include a note in it as well for people who want to
put them in httpd.conf (like me...).
Like Masi, I discovered that in httpd.conf, you have to supply the full
path (hence %{DOCUMENT_ROOT}, but in .htaccess you don't have to.
There also an issue with TYPO3 not detecting the root of the website
(t3lib_div::getIndpEnv('TYPO3_SITE_URL')) when using RealURL and the
rewrite-rules in the httpd.conf. It works correctly when the rules are
in .htacces. The problem is that the HTTP_SERVER_VARS['SCRIPT_NAME'] (if
I recall correctly) is 'just' set to the requested path, instead of just
the path to /index.php...
Maybe using a RewriteBase helps to prevent this, I haven't tested that
though...
> Now before we release this file, let's also include the stuff from the the
> file in misc/php_optimized.htaccess and place some comments in front of the
> lines we don't want to use by default:
Good idea!
> --- cut 'final' ---
> ### Begin: Rewrite stuff ###
>
> # Enably URL rewriting
> RewriteEngine On
>
> # This is important! You will have to change this path if your TYPO3
> # installation is located in a subdirectory of the website root
> RewriteBase /
>
> # Redirect http://mysite/typo3 to http://mysite/typo3/index_re.php
> # and stop the rewrite processing
> RewriteRule ^typo3$ typo3/index_re.php [L]
>
> # Stop rewrite processing if we are inside of typo3/
> RewriteRule ^typo3/ - [L]
>
> # If the file/symlink/directory does not exist => Redirect to index.php
> RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
> RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
> RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-l
> RewriteRule .* index.php
>
> ### End: Rewrite stuff ###
>
> ### Begin: PHP optimisation ###
>
> # This is disabled by default
> # Simply remove the comment marks if you want to use these settings
>
> # php_flag allow_call_time_pass_reference off
> # php_flag register_globals off
> # php_flag register_argc_argv off
> # php_flag magic_quotes_gpc off
> # php_value variables_order GPCS
>
> ### End: PHP optimisation ###
> --- cut 'final' ---
Looks good. Is it true that we don't need the slash before index.php
because of the RewriteBase?
Grtz,
Martin
More information about the TYPO3-dev
mailing list