M
M
Maxim Dyachenko2012-09-24 23:45:47
Apache HTTP Server
Maxim Dyachenko, 2012-09-24 23:45:47

Looping in mod_rewrite?

I would like to have such a config, but it naturally goes into an endless loop. Tell me how to treat?

# ***********************************************************************
# ***********************************************************************
# ***  Все html, php, htm, tpl и папки (заканчивающиеся на /)         ***
# ***  переадресуем на index.php для обработки ЧПУ и защиты.          ***
# ***  (c) 2012 Mendel AKA Max Dyachenko.                             ***
# ***********************************************************************
# ***********************************************************************
RewriteEngine on
Options +FollowSymlinks
RewriteBase /

RewriteRule ^.*\.html$ /index.php [QSA]
RewriteRule ^.*\.htm$ /index.php [QSA]
RewriteRule ^.*\.tpl$ /index.php [QSA]
RewriteRule ^.*/$ /index.php [QSA]
#
#RewriteCond %{THE_REQUEST} !"^index\.php$"
RewriteRule ^.*\.php$ /index.php [QSA]

Answer the question

In order to leave comments, you need to log in

6 answer(s)
M
Maxim Dyachenko, 2012-09-25
@Mendel

Decision:

#
RewriteRule ^.*\.html$ /index.php [L,QSA]
RewriteRule ^.*\.htm$ /index.php [L,QSA]
RewriteRule ^.*\.tpl$ /index.php [L,QSA]
RewriteRule ^.*/$ /index.php [L,QSA]
#
RewriteCond %{REQUEST_FILENAME} !index\.php$
RewriteRule ^.*\.php$ /index.php [L,QSA]

the difference from the option proposed above is that in the condition !index\.php$ and not !^index\.php$ i.e. no ^

K
Konstantin, 2012-09-24
@Norraxx

L?

N
Nazar Mokrinsky, 2012-09-25
@nazarpc

Try to put the last line before:
RewriteRule ^.*\.html$ /index.php [QSA]
The directives will spin in a circle until the output is the same result 2 times.
L just stops the current iteration of processing mod_rewrite directives

U
UncleByte, 2012-09-25
@UncleByte

Well, here it is - habrahabr.ru/post/140693/

A
Alexey, 2012-09-25
@alexkbs

Enable full logging of mod_rewrite operation . The error logs of this type are clearly visible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question