| Author |
|
nicedoggie Newbie

Joined: 21 March 2008 Location: United States
Online Status: Offline Posts: 8
|
| Posted: 19 May 2010 at 1:38pm | IP Logged
|
|
|
For some reason, I just don't get it. I have looked at the documentation but don't understand.
I have a rule that works (previous person programmed it). But I want to change it.
Presently when viewing an item, it shows the item id in the url:
http://www.musictreasures.com/instrument-pins/24541.html
I would like it to show the product name like:
http://www.musictreasures.com/instrument-pins/gold-clef-pin-24541.html
If the product name is a variable like: pDescription ... how would I rewrite that? Here is my present file:
[ISAPI_Rewrite]
#RewriteCond %REMOTE_ADDR (?!216\.230\.0\.108|24\.125\.30\.184).* #RewriteRule .* /construction.asp [I,L]
#Rewrite Links Page RewriteRule /links/([^.?]+)/? /music/linksview.asp\?linkCat=$1 [I,L]
#Rewrite Categories RewriteRule (?!/backofficelite)/([^.?]+)(?:/(?:default\.asp)?)?(?:\?(.*))? /music/categoryTemplate2.asp\?dir=$1(?2&$2) [I,L]
#Rewrite View items RewriteRule (?!/images)/([^.?]+?)/(?:default\.asp|(\d+)\.html?)(?:\?(.*))? /music/viewitem.asp\?dir2=$1&idProduct=$2?3&$3 [I,L]
Thanks! Ken
|
| Back to Top |
|
| |
Anton Admin Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 10488
|
| Posted: 20 May 2010 at 3:15am | IP Logged
|
|
|
And which of the rule is used to handle this URL http://www.musictreasures.com/instrument-pins/gold-clef-pin-24541.html ?
And where should it point? What is the real path?
Please clarify.
__________________ Regards,
Anton
|
| Back to Top |
|
| |
nicedoggie Newbie

Joined: 21 March 2008 Location: United States
Online Status: Offline Posts: 8
|
| Posted: 20 May 2010 at 3:55am | IP Logged
|
|
|
I haven't written a rule for: http://www.musictreasures.com/instrument-pins/gold-clef-pin-24541.html because I don't understand.
The rule:
RewriteRule
(?!/images)/([^.?]+?)/(?:default\.asp|(\d+)\.html?)(?:\?(.*))?
/music/viewitem.asp\?dir2=$1&idProduct=$2?3&$3 [I,L]
I believe results in:
ttp://www.musictreasures.com/instrument-pins/24541.html
I would like to modify that rule to get a result like:
http://www.musictreasures.com/instrument-pins/gold-clef-pin-24541.html
Is there documentation that will help me understand writing rules?
|
| Back to Top |
|
| |
Anton Admin Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 10488
|
| Posted: 20 May 2010 at 4:40am | IP Logged
|
|
|
ok, I see, but you haven't answered the main question: what is the real URL your request should point to?
Is it like this: /music/viewitem.asp\?dir2=instrument-pins&idProduct=24541 ?
And yes, we have docs, FAQ,
and blog.
__________________ Regards,
Anton
|
| Back to Top |
|
| |
nicedoggie Newbie

Joined: 21 March 2008 Location: United States
Online Status: Offline Posts: 8
|
| Posted: 20 May 2010 at 9:39am | IP Logged
|
|
|
Again, I apoligize for not understanding this.
http://www.musictreasures.com/music/viewitem.asp?idProduct=24541
is one way to view that item without the category in the url.
In reality, I don't need the category within the url anyway. But would like the product name embedded. The product names of course have spaces: 'Gold Clef Pin' for example. pDescription is the field name for that.
So, the result would be:
http://www.musictreasures.com/gold-clef-pin-24541.html
|
| Back to Top |
|
| |
Anton Admin Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 10488
|
| Posted: 21 May 2010 at 2:55am | IP Logged
|
|
|
Ok, I see.
So you want to request http://www.musictreasures.com/gold-clef-pin-24541.html
and see http://www.musictreasures.com/music/viewitem.asp?idProduct=24541. Here's the config for that:
RewriteRule /.+-(\d+)\.html /music/viewitem.asp?idProduct=$1 [I,L]
__________________ Regards,
Anton
|
| Back to Top |
|
| |
nicedoggie Newbie

Joined: 21 March 2008 Location: United States
Online Status: Offline Posts: 8
|
| Posted: 21 May 2010 at 9:00am | IP Logged
|
|
|
Thank you.
How can 'Gold Clef Pin' for example become part of the url without using pDescription in the rule?
Looking at this forum, the url for this thread is:
http://www.helicontech.com/forum/14844-Help_with_rules.html
You have the thread title in your url.
I would like the part description in my url.
http://www.musictreasures.com/gold-clef-pin-24541.html
the product id is 24541 and the description is "Gold Clef Pin".
I tried that rule and got an error.
|
| Back to Top |
|
| |
Anton Admin Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 10488
|
| Posted: 25 May 2010 at 2:44am | IP Logged
|
|
|
Ok, let me clarify what you need...
What is the URL you want to request, what should be displayed in the address bar and where should the content be taken from?
__________________ Regards,
Anton
|
| Back to Top |
|
| |
nicedoggie Newbie

Joined: 21 March 2008 Location: United States
Online Status: Offline Posts: 8
|
| Posted: 25 May 2010 at 9:36am | IP Logged
|
|
|
I apoligize.
The displayed url should be:
http://www.musictreasures.com/gold-clef-pin-24541.htm
At this point (presently) the displayed url for that item is like this:
http://www.musictreasures.com/instrument-pins/24541.html (not what I would like). I would like the displayed url to be like this:
http://www.musictreasures.com/gold-clef-pin-24541.htm (what I want because it has the name of the product in the url)
Now, the exisiting rules that I see are as follows:
[ISAPI_Rewrite]
#RewriteCond %REMOTE_ADDR (?!216\.230\.0\.108|24\.125\.30\.184).* #RewriteRule .* /construction.asp [I,L]
#Rewrite Links Page RewriteRule /links/([^.?]+)/? /music/linksview.asp\?linkCat=$1 [I,L]
#Rewrite Categories RewriteRule
(?!/backofficelite)/([^.?]+)(?:/(?:default\.asp)?)?(?:\?(.*))?
/music/categoryTemplate2.asp\?dir=$1(?2&$2) [I,L]
#Rewrite View items RewriteRule
(?!/images)/([^.?]+?)/(?:default\.asp|(\d+)\.html?)(?:\?(.*))?
/music/viewitem.asp\?dir2=$1&idProduct=$2?3&$3 [I,L]
I am not sure about how to achieve the results I want.
I think that the variable "pDescription" defines the product's name: "Gold Clef Pin" in the database.
Thanks again for your help.
|
| Back to Top |
|
| |
Anton Admin Group

Joined: 30 January 2007 Location: Ukraine
Online Status: Offline Posts: 10488
|
| Posted: 26 May 2010 at 4:42am | IP Logged
|
|
|
Please try to use the following for a single product:
RewriteRule /[^/]+/(\d+)\.html http\://www.musictreasures.com/gold-clef-pin-$1.htm [I,RP]
RewriteRule /gold-clef-pin-(\d+)\.htm /instrument-pins/$1\.html [I,L]
But in ISAPI_Rewrite v2, it's hardly possible to write a generic rule for all the products.
In v3, you could store product_id/product_name pairs in a mapfile (generatedbased on the database) and have one rule to care for all your
products.
__________________ Regards,
Anton
|
| Back to Top |
|
| |