This forum has been moved here:
Helicon Tech Community Forum

ISAPI_Rewrite 3.0 (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: ColdFusion 9 on Server 2008
Author
Message |
edba1970
Newbie


Joined: 10 November 2011
Location: United States
Posts: 24
Posted: 10 November 2011 at 10:36am

Hi I am new to this. I have tried many ways to enable the redirect but whatever I do, it just doesn't work. I have followed FAQ and it seems that url rewriter does work when I try RewriteRule .? - [F]. The log file also works. What am I doing wrong.
Here's the path

www.timepiecesnow.com/item.cfm?cat_name=blabla&gender=men&item_id=12345

and I want it to be re-written like so:

www.timepiecesnow.com/item/blabla/men/item-id=12345.
Back to Top Visit edba1970's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 14 November 2011 at 8:01am

Hello,

try using the following:

RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} ^cat_name=([^&]+)&gender=([^&]+)&(item_id=[^&]+)$ [NC]
RewriteRule ^item\.cfm$ /item/%1/%2/%3 [NC,R=301,L]
RewruteRule ^item/([^/]+)/([^/]+)/(tem_id=[^/]+)$ /item.cfm?cat_name=$1&gender=$2&$3 [NC,L]

Regards
Andrew
Back to Top
 
edba1970
Newbie


Joined: 10 November 2011
Location: United States
Posts: 24
Posted: 14 November 2011 at 10:13am

Thank you so much for your reply Andrew. However, I am getting an error message:

Unknown expression on line #9: RewruteRule ^item/([^/]+)/([^/]+)/(tem_id=[^/]+)$ /item.cfm?cat_name=$1&gender=$2&$3 [NC,L]

Also, I get error 404 when I do it manually: www.timepiecesnow.com/item/Hearts-on-Fire/W/item_id=10427



Edited by edba1970 - 14 November 2011 at 1:47pm
Back to Top Visit edba1970's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 16 November 2011 at 6:32am

This is a typo that I see:

RewruteRule ^item/([^/]+)/([^/]+)/(tem_id=[^/]+)$ /item.cfm?cat_name=$1&gender=$2&$3 [NC,L]

I think this must fix the issue.

Regards
Andrew
Back to Top
 
edba1970
Newbie


Joined: 10 November 2011
Location: United States
Posts: 24
Posted: 16 November 2011 at 9:17am

I can't believe I didn't see the typo.

I have tried the approach which you have posted but there are two problems

1. instead of doing: http://www.timepiecesnow.com/item/Hearts-on-Fire/woman/item_id=10427 it's doing:  http://www.timepiecesnow.com/item/Hearts-on-Fire/woman/item_id=10427?cat_name=Hearts-on-Fire&gender=woman&item_id=10427. Another words it inserts the line in between instead of removing it completely after the question mark.
2. the page does not show correctly. It writes the HTML part but all the images and all css, javascripts, and links are not pointing to the right path. When I click on them, it displays the 404 error. All links display http://www.timepiecesnow.com/item/Hearts-on-Fire/woman/item_id=10427?cat_name=Hearts-on-Fire&gender=woman&item_id=10427.

How do I fix this?

Thanks.

Edited by edba1970 - 16 November 2011 at 10:22am
Back to Top Visit edba1970's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 17 November 2011 at 7:30am

Hi,

that's easy. Try using:

Code:
RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} ^cat_name=([^&]+)&gender=([^&]+)&(item_id=[^&]+)$ [NC]
RewriteRule ^item\.cfm$ /item/%1/%2/%3? [NC,R=301,L]
RewriteRule ^item/([^/]+)/([^/]+)/(tem_id=[^/]+)$ /item.cfm?cat_name=$1&gender=$2&$3 [NC,L]


Regards
Andrew
Back to Top
 
edba1970
Newbie


Joined: 10 November 2011
Location: United States
Posts: 24
Posted: 17 November 2011 at 8:26am

How about my second question?
2. the page does not show correctly. It writes the HTML part but all the images and all css, javascripts, and links are not pointing to the right path. When I click on them, it displays the 404 error. All links display http://www.timepiecesnow.com/item/Hearts-on-Fire/woman/item_id=10427?cat_name=Hearts-on-Fire&gender=woman&item_id=10427.
Back to Top Visit edba1970's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 17 November 2011 at 8:50am

There must be some additional rule that takes part in a process.
Please, provide the config file as it is and the link to .css file.
It is also useful if you provide rewrite.log for the testing request. Logging issues described in FAQ

Regards
Andrew
Back to Top
 
edba1970
Newbie


Joined: 10 November 2011
Location: United States
Posts: 24
Posted: 17 November 2011 at 10:08am

Fixed the problem! It appears my relative paths started either with ../ or nothing at all. I replace ../ with / and added where it wasn't there. It worked like a charm. Thanks for all your help.

I do have two questions however.

1. Having the code above and wanting what we have accomplished so far, would it work if I replace a 45day trial with a lite version?

2.Also I would like to add a non www to www to my existing code. I have tried few examples from previous posts but either I get www to work or the code above works but both don't work together. How can I incorporate them both?

Thank you.


Edited by edba1970 - 17 November 2011 at 10:09am
Back to Top Visit edba1970's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 18 November 2011 at 4:49am

Hello,

1) It'll work, but please, consider the specific limitations limitations of
LITE


2) The following code is the best code so far:

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]

Just put in on the first place.

Regards
Andrew
Back to Top
 
edba1970
Newbie


Joined: 10 November 2011
Location: United States
Posts: 24
Posted: 18 November 2011 at 9:03am

That's working perfectly! I think I am falling in love with this tool. I am trying to accomplish another thing.
 
This is what I have so far:

RewriteEngine on
RewriteBase /

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]

RewriteCond %{QUERY_STRING} ^cat_name=([^&]+)&gender=([^&]+)&category=([^&]+)&item_id=([^&]+)$ [NC]
RewriteRule ^item\.cfm$ /item/%1/%2/%3/%4\.html? [NC,R=301,L]
RewriteRule ^item/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /item.cfm?cat_name=$1&gender=$2&category=$3&item_id=$4 [NC,L]

What I need is to add another rule:
http://www.timepiecesnow.com/search.cfm?item_category=Hearts-on-Fire to be changed to http://www.timepiecesnow.com/brand/Hearts-on-Fire. I was playing around with the rules which worked but when when I click on a link which supposed to go to /item/Hearts-on-Fire/woman/item_id=10427 it redirects me to /brand/item/Hearts-on-Fire/woman/item_id=10427. How can I get the brand removed when I click on a link.

I also have another question. Do I change all my links to new way or leave them and let the tool redirect the pages?

Thank you Andrew.

Back to Top Visit edba1970's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 21 November 2011 at 4:58am

Hello,

Try this one and tell me if it works:

#/search.cfm?item_category=Hearts-on-Fire --> /brand/Hearts-on-Fire.
RewriteCond %{QUERY_STRING} ^item_category=([^&]+)$ [NC]
RewriteRule ^search\.cfm$ /brand/%1? [NC,R=301,L]
RewriteRule ^brand/([^/]+)$ /search.cfm?item_category=$1 [NC,L]

Regards
Andrew

Back to Top
 
edba1970
Newbie


Joined: 10 November 2011
Location: United States
Posts: 24
Posted: 21 November 2011 at 9:13am

If I leave this as it is, it will not not work. It does not remove the brand/from path

RewriteEngine on
RewriteBase /

RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP:Host} ^(?!www\.)(.+)$ [NC]
RewriteCond %{REQUEST_URI} (.+)
RewriteRule .? http(?%1s)://www.%2%3 [R=301,L]

RewriteCond %{QUERY_STRING} ^cat_name=([^&]+)&gender=([^&]+)&category=([^&]+)&item_id=([^&]+)$ [NC]
RewriteRule ^item\.cfm$ /item/%1/%2/%3/%4\.html? [NC,R=301,L]
RewriteRule ^item/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /item.cfm?cat_name=$1&gender=$2&category=$3&item_id=$4 [NC,L]

RewriteCond %{QUERY_STRING} ^item_category=([^&]+)$ [NC]
RewriteRule ^search\.cfm$ /brand/%1? [NC,R=301,L]
RewriteRule ^brand/([^/]+)$ /search.cfm?item_category=$1 [NC,L]

This throws me from /brand/Hearts-on-Fire to /brand/item.cfm?cat_name=Hearts-On-Fire&gender=Womens&category=Jewlery&item_id=10421.
Back to Top Visit edba1970's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 22 November 2011 at 8:04am

Weird.

Can you see that you do not have a single rule pointing somewhere to /brand/....?
Would you provide the rewrite.log for the testing request?
Logging issues described in FAQ

Regards
Andrew
Back to Top
 
edba1970
Newbie


Joined: 10 November 2011
Location: United States
Posts: 24
Posted: 22 November 2011 at 1:50pm

I found my mistake and fixed that.

I have another scenario. Consider this /search.cfm?style_number_id=5&item_category=FEB. I would like the path to look like this /5/Facets-Eternity-Band. Where an abbreviated FEB is replaced with Facets-Eternity-Band. I have other abbreviated words which upon clicking, I would like them to be replaced accordingly. I was able to achieve a desired effect. However, it only works with FEB and if I click anywhere on the website, it redirects me to the same page.

RewriteEngine on
RewriteBase /

RewriteCond %{QUERY_STRING} ^style_number_id=([^&]+)&item_category=FEB$ [NC]
RewriteRule ^search\.cfm$ /%1/Facets-Eternity-Bands\.html? [NC,R=301,L]
RewriteRule ^([^/]+)/([^/]+)$ /search.cfm?style_number_id=$1&item_category=$2 [NC,L]

How do I accomplish this. By the way thank you  Andrew for your help.
Back to Top Visit edba1970's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 23 November 2011 at 5:45am

Please, consider mapfiles as an option. You can find out more in FAQ

Regards
Andrew
Back to Top
 
edba1970
Newbie


Joined: 10 November 2011
Location: United States
Posts: 24
Posted: 23 November 2011 at 10:51am

I am not familiar with the map files nor do I really understand the usage in FAQ. There is no comments on what each line does and if the mapfile's criteria is separated by space or by tab. Would you be able to help me with that? This is what I did:

RewriteEngine on
RewriteBase /

RewriteMap mapfile txt:mapfile.txt
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^search1\.cfm$ ${mapfile:%1}? [NC,R=301,L]
RewriteRule ^([^/]+)/([^/]+)$ /search1.cfm?${mapfile:%1} [NC,L]

and inside the mapfile.txt:

style_number_id=value&item_category=FEB    Facets-Eternity-Bands
style_number_id=value&item_category=FCR    Facets-Commitment-Rings

Having all this redirects me to a home page.



Edited by edba1970 - 23 November 2011 at 11:24am
Back to Top Visit edba1970's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 24 November 2011 at 5:40am

Hello,

I'd do the following thing:

Code:
# declaring mapfile name
RewriteMap mapfile txt:mapfile.txt
# matching the querysting
RewriteCond %{QUERY_STRING} (.+)
#checking if such entry exists in mapfile, if yes - continue
RewriteCond ${mapfile:%1|NOT_FOUND} !NOT_FOUND
# 301-redirect
RewriteRule ^search1\.cfm$ ${mapfile:%1}? [NC,R=301,L]


and inside the mapfile.txt:

Code:
style_number_id=value&item_category=FEB    Facets-Eternity-Bands
style_number_id=value&item_category=FCR    Facets-Commitment-Rings


Second rule to rewrite everything back:

Code:
# declaring reverse revmapfile name
RewriteMap revmapfile txt:mapfile.txt
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond ${revmapfile:$1|NOT_FOUND} !NOT_FOUND
RewriteRule ^(.+)$ /search1.cfm?${revmapfile:%1} [NC,L]


and inside the revmapfile.txt:

Code:
Facets-Eternity-Bands   style_number_id=value&item_category=FEB    
Facets-Commitment-Rings   style_number_id=value&item_category=FCR


Regards
Andrew
Back to Top
 
edba1970
Newbie


Joined: 10 November 2011
Location: United States
Posts: 24
Posted: 25 November 2011 at 10:17am

I think there is a step missing. The code doesn't do anything.
I have also few questions.

1. Is revmapfile.txt really needed?
2. do I need to have the map files in main directory where .htaccess is located?
3. Do I need to include the following at the top:
RewriteEngine on
RewriteBase /


Edited by edba1970 - 25 November 2011 at 10:19am
Back to Top Visit edba1970's Homepage
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 28 November 2011 at 5:37am

1) If you need just 301 redirect to an existing page, than there's no need in revmapfile.
In case you need to redirect to a nice URL and rewrite back to provide content for this new URl, than you need both.

2) There's an answer here

3) Sure, that's the start of each config file.

Please, try enabling logging and see error.log and rewrite.log.

Regards
Andrew
Back to Top
 

Page of 3 Next >>
 
Printable version Printable version