Hi,

I have used mod_rewrite quite a bit so I am surprised I cannot get this to work. I think the issue may be with the ? in the url but not sure.

Background:
LAMP server, php/Mysql site with mod_rewrite set up and working correctly. The main rewrite rule is this:

RewriteRule ^([^\.]+)$ /page.php?page=$1 [L]

The reason is that the client wants to have pages with no extension like .php. This works fine as the suffix is added once the php page receives the $_GET variable.

Problem:
The client uses various links to the site for marketing and now wants to use certain pages as landing pages. These pages need 6 GET vars so I have the rule:

RewriteRule ^([a-zA-Z-]+)\?a=/([0-9]+)&b=([0-9]+)&c=([0-9]+)&d=([0-9]+)&e=([0-9]+)$ /page.php?page=$1&a=$2&b=$3&c=$4&d=$5&e=$6 [L]

which I put above the main rule for these landing pages but it is only passing the first var to the page.php page. The first is the page name followed by a to e. I have tried combinations but just can't get it to work. I think it is to do with the escaped ? or am I looking in the wrong place?

There may be a better way to get the page name as the first var and then the other vars passed to the php page. The page names are dynamic or I would just use them by name which would be much easier, but there are several thousand.

Any help or pointers to tutorials will be much appreciated. I have read so many in the last 2 days but I know the answer is somewhere.

Yes, a question mark should be escaped: \? .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.