need help with 301

Sep 17, 2010 at 10:07 AM

Hi,

im having trouble adding some 301 rules in conjunction with the following rule.

my iirf.ini looks like this:

 

RewriteEngine ON

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^/(.*)$ /index.php/$1 [L]

for example if i add, i just get a 404

RedirectRule ^/test$ http://www.google.com

i've tried all sorts of 301 rules non seem to work,  could anyone help me?

Coordinator
Sep 19, 2010 at 4:12 PM
Yes, I can help. You need to remember that the rules in the ini file are processed by the iirf engine in the order in which they appear in the ini file. Your first rule matches all incoming URL requests, because you used a regex wildcard of .* . Therefore any rule that follows the first on in your ini filewill never be evaluated. If you change the order of those rules, you will see different behavior. With multiple rules in an ini file, you need to be thoughtful about ordering.
Sep 20, 2010 at 11:21 PM
Edited Sep 20, 2010 at 11:21 PM

Hi Cheeso,

Thanks very much for your reply you right it was the order, i'm still struggling though for example i have this:

 

RedirectRule ^/mains.html?page=1$ http://www.google.com

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^/(.*)$ /index.php/$1 [L]

 

and it's the same 404 but if i have

 

RedirectRule ^/mains.html$ http://www.google.com

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^/(.*)$ /index.php/$1 [L]

this does work, any ideas on what im doing wrong?

 

 

 

Coordinator
Sep 21, 2010 at 2:15 PM
The ? is a meaningful symbol in the regex language. It does not match itself. If you want to match a ? in the incoming URL, then you need to "escape" the ? using a backslash. The reason your second case works as you expect is because there is no question mark in that pattern. stepping back, it seems to me you have some basic questions. Ordering of rules and the syntax of regex are pretty basic issues. These and other basic topics are all addressed in the documentation I provide with the filter. Take the time to read it, and you'll have fewer problems, less frustration, and much quicker success with IIRF. Good luck.