Adding parameter to mapfile rule
12 posts
• Page 1 of 1
Adding parameter to mapfile rule
Hi,
I need to add a parameter to these mapfile rules (to also accept a category id).
The url structure:
/cal.asp?id=5&lng=se
/cal.asp?id=6&lng=se
The "pretty url" (sample):
/se/title-of-the-page
/se/another-title
New url structure
/cal.asp?id=5&lng=se&cat=4 <-- added category parameter (it's going to fetch the category name)
/cal.asp?id=6&lng=se&cat=3
The new "pretty url" (sample)
/se/news/title-of-the-page <-- category news
/se/press/another-title <-- category press
The .htaccess
----------------
I've kind of got it working by modifying the rule as follows:
-------------------------------------------------------------------
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/([^/.]+)$ [NC] <-- added
RewriteCond ${calendar_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_se:${lower:%2}}&lng=%1&cat=%1 [NC,L] <-- added parameter
But it only accepts the "pretty url" if I put the "category" last, ex.
/se/title-of-the-page/news <--
instead of:
/se/news/title-of-the-page
The mapfile looks like this:
-------------------------------
Please note - I have two similar rules for the english and the german pages, but I guess that these could be modifed in the same way.
Kind Regards
/ Anejo
I need to add a parameter to these mapfile rules (to also accept a category id).
The url structure:
/cal.asp?id=5&lng=se
/cal.asp?id=6&lng=se
The "pretty url" (sample):
/se/title-of-the-page
/se/another-title
New url structure
/cal.asp?id=5&lng=se&cat=4 <-- added category parameter (it's going to fetch the category name)
/cal.asp?id=6&lng=se&cat=3
The new "pretty url" (sample)
/se/news/title-of-the-page <-- category news
/se/press/another-title <-- category press
The .htaccess
----------------
- Code: Select all
RewriteEngine on
RewriteBase /
## CALENDAR MAPFILES
RewriteMap calendar_se txt:mfiles/calendar_se.txt
# Calendar
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)$ [NC]
RewriteCond ${calendar_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_se:${lower:%2}}&lng=%1 [NC,L]
I've kind of got it working by modifying the rule as follows:
-------------------------------------------------------------------
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/([^/.]+)$ [NC] <-- added
RewriteCond ${calendar_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_se:${lower:%2}}&lng=%1&cat=%1 [NC,L] <-- added parameter
But it only accepts the "pretty url" if I put the "category" last, ex.
/se/title-of-the-page/news <--
instead of:
/se/news/title-of-the-page
The mapfile looks like this:
-------------------------------
- Code: Select all
title-of-the page 5
another-title 6
Please note - I have two similar rules for the english and the german pages, but I guess that these could be modifed in the same way.
Kind Regards
/ Anejo
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Adding parameter to mapfile rule
hello,
In the following rule:
The %1 and %2( also %3) are the values of the variables captured in (...). In this pattern /([^/]+)/([^/.]+)/([^/.]+) there're 3 values and you're using 2 similar %1 values.
Regards
Andrew
In the following rule:
- Code: Select all
RewriteRule .? /cal.asp?id=${calendar_se:${lower:%2}}&lng=%1&cat=%1 [NC,L] <-- added parameter
The %1 and %2( also %3) are the values of the variables captured in (...). In this pattern /([^/]+)/([^/.]+)/([^/.]+) there're 3 values and you're using 2 similar %1 values.
Regards
Andrew
Re: Adding parameter to mapfile rule
Hi Andrew,
I tried this but it didn't work
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/([^/.]+)$ [NC]
RewriteCond ${calendar_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_se:${lower:%2}}&lng=%1&cat=%3 [NC,L]
The querystring is:
----------------------
/cal.asp?id=5&lng=se&cat=4
And the "pretty url":
------------------------
/se/press/title-of-the-page
And the mapfile (calendar_se) is:
Kind Regards
/ Anette
I tried this but it didn't work
RewriteCond %{REQUEST_URI} ^/([^/]+)/([^/.]+)/([^/.]+)$ [NC]
RewriteCond ${calendar_se:${lower:%2}|NOT_FOUND} !NOT_FOUND
RewriteRule .? /cal.asp?id=${calendar_se:${lower:%2}}&lng=%1&cat=%3 [NC,L]
The querystring is:
----------------------
/cal.asp?id=5&lng=se&cat=4
And the "pretty url":
------------------------
/se/press/title-of-the-page
And the mapfile (calendar_se) is:
- Code: Select all
title-of-the page 5
another-title 6
Kind Regards
/ Anette
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Adding parameter to mapfile rule
According to your rule the resulting URL would be:
/cal.asp?id=VariableFrom_calendar_se&lng=se&cat=title-of-the page instead of /cal.asp?id=5&lng=se&cat=4
If you want to replace all values with the digits, than you need 2 or 3 mapfiles, not just passing the parameter.
Regards
Andrew
/cal.asp?id=VariableFrom_calendar_se&lng=se&cat=title-of-the page instead of /cal.asp?id=5&lng=se&cat=4
If you want to replace all values with the digits, than you need 2 or 3 mapfiles, not just passing the parameter.
Regards
Andrew
Re: Adding parameter to mapfile rule
I'm not sure we're on the same page?
The underlying url is the querystring but the display to the user should be:
www.mysite.com/se/press/page-title
I use this url on all menus, internal links etc. as well
In the database I have these fields
real_url : /cal.asp?id=5&lng=se&cat=5
publicURL : /se/press/page-title <-- this is displayed on menus, internal links etc.
/ Anette
The underlying url is the querystring but the display to the user should be:
www.mysite.com/se/press/page-title
I use this url on all menus, internal links etc. as well
In the database I have these fields
real_url : /cal.asp?id=5&lng=se&cat=5
publicURL : /se/press/page-title <-- this is displayed on menus, internal links etc.
/ Anette
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Adding parameter to mapfile rule
I do understand what happens. It's just instead of giving a right rule, I'm telling you what is not working so that you can fix it yourself.
I'm telling you that the rule needs to have both id and cat parameters drawn through the mapfiles
I'm telling you that the rule needs to have both id and cat parameters drawn through the mapfiles
Re: Adding parameter to mapfile rule
Hi Andrew,
OK so do you mean that the new parameter cat (category_id) needs to have an additional mapfile?
That means two mapfiles, one for storing the id and another for storing the category_id?
I can have 2 parameters for a single mapfile (ie lang and id) but not three?
And it's not possible to store "/" in a mapfile, because that would be sufficient actually
Like:
press/my-title 5
press/my-other-title 6
news/another-title 7
I really don't get this, I'm sorry ...
Is it possible to buy some time from you in order to solve this?
I have a ton of other tasks to solve on this system, and also have a deadline approaching so I'm a bit stressed out on this
Kind Regards
/ Anette
OK so do you mean that the new parameter cat (category_id) needs to have an additional mapfile?
That means two mapfiles, one for storing the id and another for storing the category_id?
I can have 2 parameters for a single mapfile (ie lang and id) but not three?
And it's not possible to store "/" in a mapfile, because that would be sufficient actually
Like:
press/my-title 5
press/my-other-title 6
news/another-title 7
I really don't get this, I'm sorry ...
Is it possible to buy some time from you in order to solve this?
I have a ton of other tasks to solve on this system, and also have a deadline approaching so I'm a bit stressed out on this
Kind Regards
/ Anette
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Adding parameter to mapfile rule
Correct, you need 2 of those as you're converting 2 different types of parameters:
and
Sure, you can buy Premium Support Plan and discuss everything online or ever let us do everything for you.
Regards
Andrew
- Code: Select all
my-title 5
my-other-title 6
another-title 7
and
- Code: Select all
news 1
category 2
category_other 3
Sure, you can buy Premium Support Plan and discuss everything online or ever let us do everything for you.
Regards
Andrew
Re: Adding parameter to mapfile rule
Hi Andrew,
I've registered and payed for the premium supportplan. I'm posting a ticket in a moment.
Kind Regards
/ Anette
I've registered and payed for the premium supportplan. I'm posting a ticket in a moment.
Kind Regards
/ Anette
Re: Adding parameter to mapfile rule
Hellloooo!!!
No answer in the premium support and no answer here!
????
/ Anette
No answer in the premium support and no answer here!
????
/ Anette
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Adding parameter to mapfile rule
Anette, it's stated at the support page that we're located at +2GMT. There're also our working hours stated there.
Your premium ticket at helpdesk was answered hour-two ago, please, see helpdesk.
Regards
Andrew
Your premium ticket at helpdesk was answered hour-two ago, please, see helpdesk.
Regards
Andrew
12 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests