| Author |
|
PaulHelyer Newbie

Joined: 11 July 2008
Online Status: Offline Posts: 7
|
| Posted: 11 July 2008 at 5:58am | IP Logged
|
|
|
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 |
|
| |
Lexey Moderator Group

Joined: 15 August 2002 Location: Russian Federation
Online Status: Offline Posts: 7389
|
| Posted: 12 July 2008 at 12:38pm | IP Logged
|
|
|
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 |
|
| |
PaulHelyer Newbie

Joined: 11 July 2008
Online Status: Offline Posts: 7
|
| Posted: 12 July 2008 at 1:58pm | IP Logged
|
|
|
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 |
|
| |
Lexey Moderator Group

Joined: 15 August 2002 Location: Russian Federation
Online Status: Offline Posts: 7389
|
| Posted: 13 July 2008 at 4:19pm | IP Logged
|
|
|
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 |
|
| |
PaulHelyer Newbie

Joined: 11 July 2008
Online Status: Offline Posts: 7
|
| Posted: 16 July 2008 at 6:28am | IP Logged
|
|
|
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 |
|
| |
PaulHelyer Newbie

Joined: 11 July 2008
Online Status: Offline Posts: 7
|
| Posted: 16 July 2008 at 12:44pm | IP Logged
|
|
|
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 |
|
| |
tilly Groupie

Joined: 24 June 2008 Location: Neutral Zone
Online Status: Offline Posts: 49
|
| Posted: 16 July 2008 at 1:45pm | IP Logged
|
|
|
Hi!,
Please try
Code:
|
RewriteRule /cafe-menu/([\w\-]+)\.html /cafe-menu/index.cfm\?page=$1 |
|
|
|
| Back to Top |
|
| |
PaulHelyer Newbie

Joined: 11 July 2008
Online Status: Offline Posts: 7
|
| Posted: 17 July 2008 at 4:04am | IP Logged
|
|
|
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 |
|
| |
tilly Groupie

Joined: 24 June 2008 Location: Neutral Zone
Online Status: Offline Posts: 49
|
| Posted: 17 July 2008 at 4:22am | IP Logged
|
|
|
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 |
|
| |
PaulHelyer Newbie

Joined: 11 July 2008
Online Status: Offline Posts: 7
|
| Posted: 17 July 2008 at 4:38am | IP Logged
|
|
|
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 |
|
| |
tilly Groupie

Joined: 24 June 2008 Location: Neutral Zone
Online Status: Offline Posts: 49
|
| Posted: 17 July 2008 at 4:55am | IP Logged
|
|
|
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 |
|
| |
PaulHelyer Newbie

Joined: 11 July 2008
Online Status: Offline Posts: 7
|
| Posted: 17 July 2008 at 4:58am | IP Logged
|
|
|
I did not have the first line in there before, but now I do - and still the same problem.
|
| Back to Top |
|
| |
Lexey Moderator Group

Joined: 15 August 2002 Location: Russian Federation
Online Status: Offline Posts: 7389
|
| Posted: 28 July 2008 at 5:08pm | IP Logged
|
|
|
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 |
|
| |