Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x support forum
 Helicon Tech : ISAPI_Rewrite 2.x support forum
Subject Topic: New user how to Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
PaulHelyer
Newbie
Newbie


Joined: 11 July 2008
Online Status: Offline
Posts: 7
Posted: 11 July 2008 at 5:58am | IP Logged Quote PaulHelyer

Hi all,

I am just looking to use ASAPI Rewrite 2 on a site and would like some advice on the best way to rewrite SEO friendly URLs.

I have a database which holds my menu items in a table which is linked to a second table containing menu pages.

My page structure at the moment is along the lines of:
www.mysite.com/cafe-menu/index.cfm?mPage=1

The column mPage 1 in the database contains the page title "Starters".

How would I use ASAPI Rewrite 2 to change this URL to:
www.mysite.com/cafe-menu/starters.html

Many thanks in advance.
Paul
Back to Top View PaulHelyer's Profile Search for other posts by PaulHelyer
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7389
Posted: 12 July 2008 at 12:38pm | IP Logged Quote Lexey

There are two possible solutions:
1) You could modify index.cfm to accept a page name as a parameter instead of id. Then you could use the following generic rule:

RewriteRule /cafe-menu/(\w+)\.html /cafe-menu/index.cfm\?page=$1 [I,L]

2) You could write a separate rule for each possible page Id. For the give sample the rule is:

RewriteRule /cafe-menu/starters\.html /cafe-menu/index.cfm\?mPage=1 [I,L]

However, we do not recommend to use this solution if a number of different IDs is large than 50-100.

For the ISAPI_Rewrite 3 there is a good alternative to the option 2) - map files.
Back to Top View Lexey's Profile Search for other posts by Lexey
 
PaulHelyer
Newbie
Newbie


Joined: 11 July 2008
Online Status: Offline
Posts: 7
Posted: 12 July 2008 at 1:58pm | IP Logged Quote PaulHelyer

Thanks for your reply Lexey,

My httpd.ini now says:
RewriteRule /cafe-menu/(\w+)\.html /cafe-menu/index.cfm\?page=$1 [I,L]

Whenever I browse to http://www.mysite.com/cafe-menu/index.cfm?page=testing, I would expect the URL to display:
http://www.mysite.com/cafe-menu/testing.html

Have I misunderstood this?

Many thanks,
Paul
Back to Top View PaulHelyer's Profile Search for other posts by PaulHelyer
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7389
Posted: 13 July 2008 at 4:19pm | IP Logged Quote Lexey

This rule will only allow you to write http://www.mysite.com/cafe-menu/testing.html instead of http://www.mysite.com/cafe-menu/index.cfm?page=testing. It will not change any existing links. You will need to change them manually.
Back to Top View Lexey's Profile Search for other posts by Lexey
 
PaulHelyer
Newbie
Newbie


Joined: 11 July 2008
Online Status: Offline
Posts: 7
Posted: 16 July 2008 at 6:28am | IP Logged Quote PaulHelyer

OK,

I must be doing something wrong here - I am using this rule:

RewriteRule /cafe-menu/(\w+)\.html /cafe-menu/index.cfm\?page=$1 [I,L]

If I view the page http://www.mysite.co.uk/cafe-menu/index.cfm?page=Test-page, the page loads fine.
File not found: /cafe-menu/Test-page.html If I view http://www.mysite.co.uk/cafe-menu/Test-page.html I get an error saying "File not found: /cafe-menu/Test-page.html"

Where am I going wrong?  What else should I check?

Thanks in advance,
Paul
Back to Top View PaulHelyer's Profile Search for other posts by PaulHelyer
 
PaulHelyer
Newbie
Newbie


Joined: 11 July 2008
Online Status: Offline
Posts: 7
Posted: 16 July 2008 at 12:44pm | IP Logged Quote PaulHelyer

Just read that last post and it was a bit scrambled.  Here is what i meant to say:

OK,

I must be doing something wrong here - I am using this rule:

RewriteRule /cafe-menu/(\w+)\.html /cafe-menu/index.cfm\?page=$1 [I,L]

If I view the page http://www.mysite.co.uk/cafe-menu/index.cfm?page=Test-page, the page loads fine.

If I view http://www.mysite.co.uk/cafe-menu/Test-page.html I get an error saying "File not found: /cafe-menu/Test-page.html"

Where am I going wrong?  What else should I check?

Thanks in advance,
Paul
Back to Top View PaulHelyer's Profile Search for other posts by PaulHelyer
 
tilly
Groupie
Groupie


Joined: 24 June 2008
Location: Neutral Zone
Online Status: Offline
Posts: 49
Posted: 16 July 2008 at 1:45pm | IP Logged Quote tilly

Hi!,

Please try
Code:

RewriteRule /cafe-menu/([\w\-]+)\.html /cafe-menu/index.cfm\?page=$1

 

Back to Top View tilly's Profile Search for other posts by tilly
 
PaulHelyer
Newbie
Newbie


Joined: 11 July 2008
Online Status: Offline
Posts: 7
Posted: 17 July 2008 at 4:04am | IP Logged Quote PaulHelyer

Hi Tilly,

Thank you, but still the same.  My file contains just this rul and nothing more - is that correct? 

Is there anything else I need to do in order for this to work?

Am I correct in thinking that the page at http://www.mysite.co.uk/cafe-menu/index.cfm?page=Test-page *should* be displaying if I browse to http://www.mysite.co.uk/cafe-menu/Test-page.html?

Many thanks,
Paul
Back to Top View PaulHelyer's Profile Search for other posts by PaulHelyer
 
tilly
Groupie
Groupie


Joined: 24 June 2008
Location: Neutral Zone
Online Status: Offline
Posts: 49
Posted: 17 July 2008 at 4:22am | IP Logged Quote tilly

Do you have the, RewriteEngine on?

And yes this is the url youde browse

http://www.mysite.co.uk/cafe-menu/Test-page.html

 

Back to Top View tilly's Profile Search for other posts by tilly
 
PaulHelyer
Newbie
Newbie


Joined: 11 July 2008
Online Status: Offline
Posts: 7
Posted: 17 July 2008 at 4:38am | IP Logged Quote PaulHelyer

My host assures me that that is on, and they uninstalled then reinstalled and still I get the same.

Strangely, the error I get is a ColdFusion page not found handler.  If I go to Test-page.htm instead of Test-page.html I get the browsers 404 error.
Back to Top View PaulHelyer's Profile Search for other posts by PaulHelyer
 
tilly
Groupie
Groupie


Joined: 24 June 2008
Location: Neutral Zone
Online Status: Offline
Posts: 49
Posted: 17 July 2008 at 4:55am | IP Logged Quote tilly

In the httpd.ini do you have

Code:
RewriteEngine on

RewriteRule /cafe-menu/([\w\-]+)\.html /cafe-menu/index.cfm\?page=$1

The url must end in .html in this case.

Back to Top View tilly's Profile Search for other posts by tilly
 
PaulHelyer
Newbie
Newbie


Joined: 11 July 2008
Online Status: Offline
Posts: 7
Posted: 17 July 2008 at 4:58am | IP Logged Quote PaulHelyer

I did not have the first line in there before, but now I do - and still the same problem.
Back to Top View PaulHelyer's Profile Search for other posts by PaulHelyer
 
Lexey
Moderator Group
Moderator Group


Joined: 15 August 2002
Location: Russian Federation
Online Status: Offline
Posts: 7389
Posted: 28 July 2008 at 5:08pm | IP Logged Quote Lexey

Show exact contents of your httpd.ini.
Note, that "RewriteEngine on" is meaningless for the ISAPI_Rewrite 2. httpd.ini should start with:
[ISAPI_Rewrite]
section marker.
Back to Top View Lexey's Profile Search for other posts by Lexey
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum