[Typo3-dev] Bug in .htaccess?
Michael Stucki
mundaun at gmx.ch
Thu Apr 29 11:34:41 CEST 2004
Hi Andreas,
> There are IMHO two problems with the official .htaccess file.
> I think it would be the right time to correct all the packages before
> realeasing them with the new TYPO3 version.
I see. I didn't looked at these htaccess files for months.
First thing is that the quickstart package has a different htaccess file
than the other two sites:
--- cut ---
RewriteEngine On
RewriteRule ^[^/]*\.html$ index.php
--- cut ---
Anyway. It's not perfect either...
> The current version of .htaccess:
>
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^typo3$ typo3/index_re.php
> RewriteRule ^[^/]*\.html$ index.php
>
>
> the condition is made for the second rewrite rule but does not affect
> this - it only can affect the one next rewrite rule (that one for the
> backend, where it does not make sense. The right order where:
If I understand this right, this means that currently all *.html files are
getting redirected to index.php even if they're existing, because the
condition is only valid for the first rule. While the second rule matches
for any request. Right?
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^[^/]*\.html$ index.php
> RewriteRule ^typo3$ typo3/index_re.php
This is even better, right.
> In order to make this rule work also for windows it has to have a slash
> before the target file / dir:
>
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteRule ^[^/]*\.html$ /index.php
> RewriteRule ^typo3$ /typo3/index_re.php
>
> this version works also on Linux for me.
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?
> if it is true, we test it and then maybe can Ingmar and Michael patch
> the packages.
Of course.
Btw, would it make sense to include an example for the RealUrl extension?
Does this example work anywhere? Please check this if you are using the
extension. I have taken the rule from the extension manual [1]:
--- cut ---
RewriteEngine On
RewriteRule ^/typo3$ - [L]
RewriteRule ^/typo3/.*$ - [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-l
RewriteRule .* /index.php
--- cut ---
This looks still not perfect to me. There is an annotation on the bottom of
that page, and additionally I did remove the trailing slashes in the rules
here:
--- cut ---
RewriteEngine On
RewriteRule ^typo3$ typo3/index_re.php [L]
RewriteRule ^typo3/.*$ - [L]
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-l
RewriteRule .* index.php
--- cut ---
Of course, if the site is located in a subdirectory of the web root, we will
need to modify the RewriteBase manually.
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:
--- 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' ---
Any comments?
Regards - michael
[1]
http://typo3.org/documentation/document-library/realurl/Configuration-87/
--
Want support? Please read the list rules first: http://typo3.org/1438.0.html
More information about the TYPO3-dev
mailing list