Project

General

Profile

Actions

Bug #25191

closed

.htaccess contains uneccesary rewrite rules

Added by Michiel Roos over 13 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2011-02-27
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.5
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

http://forge.typo3.org/projects/typo3v4-core/repository/entry/trunk/_.htaccess

Rule 1:
- Never rewrite 'static' resources. That would be silly right? If a certain request exists as an actual file on the filesystem: serve the file.

Rule 2
- Rewrite everything else.

Rule 3
- wrap the rewrite stuff with an <ifModule > to avoid 500 errors.

Ship with this .htaccess enabled by default.

-------------------------------------------------------------------------------------------
<IfModule mod_rewrite.c>
  1. Enable URL rewriting
    RewriteEngine On
  1. Change this path, if your TYPO3 installation is located in a subdirectory of the website root.
    #RewriteBase /
  1. Rule for versioned static files, configured through:
  2. - $TYPO3_CONF_VARS['BE']['versionNumberInFilename']
  3. - $TYPO3_CONF_VARS['FE']['versionNumberInFilename']
  4. IMPORTANT: This rule has to be the very first RewriteCond in order to work!
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L]
  1. Do not rewrite static resources
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d [OR]
    RewriteCond %{REQUEST_FILENAME} -l
    RewriteRule .* - [L]
  1. Rewrite the rest to index.php
    RewriteRule .* /index.php [L]
    </IfModule>
    -------------------------------------------------------------------------------------------

The rewrite rules are there to push out FE content as fast as possible. So TYPO3 backend rewrite rules have no place in the .htaccess (and they don't make sense if you use the newly proposed rules).

The following lines make no sense to me:


  1. Stop rewrite processing, if we are in the typo3/ directory.
  2. For httpd.conf, use this line instead of the next one:
  3. RewriteRule ^/TYPO3root/(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]
    RewriteRule ^(typo3/|t3lib/|fileadmin/|typo3conf/|typo3temp/|uploads/|favicon\.ico) - [L]
  1. Redirect http://example.com/typo3 to http://example.com/typo3/index_re.php and stop the rewrite processing.
  2. For httpd.conf, use this line instead of the next one:
  3. RewriteRule ^/TYPO3root/typo3$ /TYPO3root/typo3/index.php [L]
    RewriteRule ^typo3$ typo3/index_re.php [L]
  1. If the file/symlink/directory does not exist => Redirect to index.php.
  2. For httpd.conf, you need to prefix each '%{REQUEST_FILENAME}' with '%{DOCUMENT_ROOT}'.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    (issue imported from #M17783)

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #16658: Wrong information in _.htaccess for httpd.conf configurationClosed2006-10-19

Actions
Actions #1

Updated by Chris topher over 13 years ago

Hi Michiel,

can you check, if the "/TYPO3root" at the beginning of the 2 rules is correct there?
This would then also solve #16658.

Actions #2

Updated by Sigfried Arnold over 13 years ago

I use that for quite a long time now and it showed no problems

  1. fix for RTE Magic Image and absRefPrefix (optional)
    RewriteRule ^(?:.+)uploads/(.*?)$ /uploads/$1 [R,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule .* - [L]

RewriteRule ^typo3$ typo3/ [L]

RewriteRule .* index.php [L]

Actions #3

Updated by Dmitry Dulepov over 13 years ago

Ship with this .htaccess enabled by default.

We discussed that several times and we decided not to do it. That part is closed for now.

Actions #4

Updated by Markus Klein almost 13 years ago

  • Target version deleted (0)

Hi Michiel,

could you please provide a complete patch for your proposed changes?

Thank you.

Actions #5

Updated by Stefan Galinski over 12 years ago

  • Category deleted (Communication)
  • Status changed from New to Needs Feedback
Actions #6

Updated by Alexander Opitz over 11 years ago

Hi,

as this issue is very old. Does the problem still exists within newer versions of TYPO3 CMS (4.5 or 6.1)?

Actions #8

Updated by Markus Klein over 11 years ago

@Michiel: As asked one year ago, could you please push a patch with your suggestion and/or upload a modified version of the .htaccess file with your suggestions here?

Actions #9

Updated by Gerrit Code Review over 11 years ago

  • Status changed from Needs Feedback to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/22529

Actions #10

Updated by Gerrit Code Review almost 11 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/22529

Actions #11

Updated by Gerrit Code Review almost 11 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/22529

Actions #12

Updated by Gerrit Code Review almost 11 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/22529

Actions #13

Updated by Michiel Roos almost 11 years ago

Please close this issue.

Actions #14

Updated by Markus Klein almost 11 years ago

  • Status changed from Under Review to Closed
  • Is Regression set to No
Actions

Also available in: Atom PDF