Forum Moderators: phranque

Message Too Old, No Replies

redirect priorities & orders

         

filipmedia

2:06 am on Mar 20, 2010 (gmt 0)

10+ Year Member



I have the following two redirect rules on place

#RULE1:

Redirect 301 /razno-iz-znanosti/zivotopisi-velikana/blablabla http://www.example.com/someurl.html

#RULE2:

RewriteCond %{REQUEST_URI} /razno-iz-znanosti/zivotopisi-velikana/[\d]+-.*?$
RewriteRule zivotopisi-velikana/[\d]+-(.*?)$ http://www.example.com/zivotopisi-velikana/$1 [L]

The problem is that the first rule will be ignored and it will get redirected by the second rule. How do i set so it uses the first rule before applying the second?

The first rule is positioned above the second rule in the .htaccess but that doesnt seem to have affect.

Thank you

[edited by: jdMorgan at 10:13 pm (utc) on Mar 20, 2010]
[edit reason] example.com [/edit]

jdMorgan

10:13 pm on Mar 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No it does not have any effect, because .htaccess code is not a sequentially-executed "script."

Instead, each Apache module 'scans' your .htaccess file, and executes only the directives that it understands. Therefore, it is the module execution order that controls directive execution order, and not the other way 'round. Obviously, your server is configured to execute mod_rewrite before executing mod_alias.

The solution is to replace your mod_alias "Redirect 301" directive with a mod_rewrite RewriteRule. When both directives belong to the same Apache module, then they will execute in the order that you specify.

Jim