Simple rewrite rule for passing CGI parameters
5 posts
• Page 1 of 1
- amaninkent1
- Posts: 3
- Joined: 03 Apr 2012, 15:49
Simple rewrite rule for passing CGI parameters
Hi,
I have been trying, without luck, to form a rewrite to capture incoming requests that have page numbers, like this:
http://www.xyz.com/strawberry-milkshakes.cfm?page=1
I have this:
RewriteRule ([^\?]*)/strawberry-milkshakes.cfm$ $1/catpage.cfm?Category_ID=100 [L]
so that the page "strawberry-milkshakes.cfm" is served by my generic catpage.cfm template, which passes Category_ID 100 in this case (other flavours have other Category_ID values).
However, I cannot get pagination to work. I need to pass the page parameter as well, if it exists. Someone may request:
http://www.xyz.com/strawberry-milkshakes.cfm?page=1
so I need Category_ID = 100 and page = 1 passed back.
Can anyone please show me the syntax? Do I need one rule or two?
Help appreciated.
Thanks,
Mark
I have been trying, without luck, to form a rewrite to capture incoming requests that have page numbers, like this:
http://www.xyz.com/strawberry-milkshakes.cfm?page=1
I have this:
RewriteRule ([^\?]*)/strawberry-milkshakes.cfm$ $1/catpage.cfm?Category_ID=100 [L]
so that the page "strawberry-milkshakes.cfm" is served by my generic catpage.cfm template, which passes Category_ID 100 in this case (other flavours have other Category_ID values).
However, I cannot get pagination to work. I need to pass the page parameter as well, if it exists. Someone may request:
http://www.xyz.com/strawberry-milkshakes.cfm?page=1
so I need Category_ID = 100 and page = 1 passed back.
Can anyone please show me the syntax? Do I need one rule or two?
Help appreciated.
Thanks,
Mark
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Simple rewrite rule for passing CGI parameters
Hello,
What request do you want to make from a browser? Where should it point to?
this will help to create a simple rule(s)
regards
Andrew
What request do you want to make from a browser? Where should it point to?
this will help to create a simple rule(s)
regards
Andrew
- amaninkent1
- Posts: 3
- Joined: 03 Apr 2012, 15:49
Re: Simple rewrite rule for passing CGI parameters
>What request do you want to make from a browser? Where should it point to?
Say that I enter:
http://www.xyz.com/strawberry-milkshakes.cfm?page=3
the page should load:
http://www.xyz.com/strawberry-milkshake ... 100&page=3
but only show http://www.xyz.com/strawberry-milkshakes.cfm?page=3 in the browser.
I have this rule at present:
RewriteRule ([^\?]*)/strawberry-milkshakes.cfm$ $1/catpage.cfm?Category_ID=100 [L]
Thanks,
Mark
Say that I enter:
http://www.xyz.com/strawberry-milkshakes.cfm?page=3
the page should load:
http://www.xyz.com/strawberry-milkshake ... 100&page=3
but only show http://www.xyz.com/strawberry-milkshakes.cfm?page=3 in the browser.
I have this rule at present:
RewriteRule ([^\?]*)/strawberry-milkshakes.cfm$ $1/catpage.cfm?Category_ID=100 [L]
Thanks,
Mark
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Simple rewrite rule for passing CGI parameters
Hello,
In this case it's only one rule. I see that you need your Category_ID=100 static, so the rule should look like:
Regards
Andrew
In this case it's only one rule. I see that you need your Category_ID=100 static, so the rule should look like:
- Code: Select all
RewriteCond %{QUERY_StRING} ^page=([^&]+)$
RewriteRule ^strawberry-milkshakes\.cfm$ /strawberry-milkshakes.cfm?Category_ID=100 [NC,QSA,L]
Regards
Andrew
- amaninkent1
- Posts: 3
- Joined: 03 Apr 2012, 15:49
Re: Simple rewrite rule for passing CGI parameters
Thanks Andrew.
In fact, I only needed to add QSA and it works.
In fact, I only needed to add QSA and it works.
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 23 guests