Forum Moderators: phranque

Message Too Old, No Replies

Rewrite stops

         

etdebruin

5:17 am on Jul 8, 2006 (gmt 0)

10+ Year Member



I have two rules. As it is now, the first rule seems to include the second rule because when I click on the link described in the second rule, I just get a blank page. But when I comment out the first rule, I am able to access the page described in the second rule.

Can anyone help?

rewriteRule ^$ index.php?nav=p-1&clickpath=index [NC,L]

rewriteRule ^company/job-opportunities(/.*)?/?$ /mcms_page.php?nav=p-40&clickpath=company/job-opportunities&wildcard=$1 [QSA,NC,L]

etdebruin

5:10 am on Jul 8, 2006 (gmt 0)

10+ Year Member



I would like to have:

[test.com...]

mod rewrite to say

index.php?page=1

My problem is that I use the following rewrite which seems to work on Unix systems but not on Windows Apache systems:

rewriteRule ^/?$ /index.php?page=1 [NC,L]

I think there is something wrong with my regex - can anyone help?

jdMorgan

12:17 pm on Jul 8, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



1) Is your code in .htaccess, or in httpd.conf?
2) Do you have a DirectoryIndex directive in that file, too?
(If so, what does it say?)
3) What is the setting of Options Indexes?

Jim

etdebruin

2:24 pm on Jul 8, 2006 (gmt 0)

10+ Year Member



I can get that info from the Client. But in the meantime, could you let me know what they should be in order for this to work?

etdebruin

3:09 pm on Jul 10, 2006 (gmt 0)

10+ Year Member



I am using .htaccess for the configuration of mod rewrite rules.

Within the httpd.conf we have the following:

We have the following for DirectIndex:

DirectoryIndex index.cfm index.html index.html.var index.php

And we have no Options indexes entry

jdMorgan

4:41 pm on Jul 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want to rewrite requests for "/", you may need to turn off DirectoryIndex so that it won't grab the request before mod_rewrite can handle it.

Alternatively, you could try rewriting requests for "index.php" instead; DirectoryIndex will rewrite "/" requests to index.php, and then mod_rewrite can rewrite index.php requests to index.php?nav=p-1&clickpath=index if those two query string parameters are blank.

Just realize that Apache modules execute one-by-one, each parsing your .htaccess file in turn for directives that it understands, and that there are several modules that can 'rewrite' the requested URL. Your mod_rewrite rules must take into account the actions of mod_dir, mod_alias, and even your php interpreter *if* they run before mod_rewrite does.

The order of execution of Apache modules is controlled by the *reverse* httpd.conf LoadModule list order in Apache 1.x and by a vaguely-described internal priority scheme in Apache 2.x.

Taking a shot in the dark, the following change *may* prevent two modules from interfering with each other and causing an 'infinite' rewrite loop:


RewriteCond %{QUERY_STRING} !nav=p-1
RewriteCond %{QUERY_STRING} !clickpath=index
RewriteRule ^$ index.php?nav=p-1&clickpath=index [NC,L]

Jim

[edited by: jdMorgan at 5:30 pm (utc) on July 10, 2006]