• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

url rewriting

Explorer ,
Apr 07, 2011 Apr 07, 2011

Copy link to clipboard

Copied

If I have a dynamic page that loads content depending on a url parameter (whatever.com/editorial.cfm?id=35), how can I rewrite that to make sense? For every record, I do have a "title" for the editorial, like "The best eateries in town" for instance. Any way to use that in the url instead of the id and still have the id recognized on article.cfm?

Views

14.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 07, 2011 Apr 07, 2011

Copy link to clipboard

Copied

Does your server have any form of a "URL Rewriter" tool available?  Is it a Windows or Linux server?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 07, 2011 Apr 07, 2011

Copy link to clipboard

Copied

Windows: Microsoft-IIS/7.5

I've looked around for a url rewriting tool from the host, but if their forum is any indication, it doesn't exist.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 07, 2011 Apr 07, 2011

Copy link to clipboard

Copied

IIS7 has its own rewrite engine, if it's not installed (it's an addon) I'd ask the host if they can install it for you; it's an official Microsoft add-on and doesn't cause any problems. I work for a hosting company and we always install it by default now. Once installed, you can configure your rewrite rules using a web.config file in your web root, so you don't need to contact your hosts to make changes.

Trying to do rewriting in CF is a massive pain, with lots of potential issues with error and 404 handlers and even then it'll only handle pages it's given, such as .cfm, .cfml etc; it won't be able to rewrite any non-CF requests, such as .htm etc.

Rewriting is *definitely* something to be done at the webserver level.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 08, 2011 Apr 08, 2011

Copy link to clipboard

Copied

So what you're saying is you want an URL like this:

http://whatever.com/editorial/The_best_eateries_in_town/

I agree this is best done via some sort of ISAPI_rewrite module, and not via CF.

How many articles have you got?  One way to do this would be to generate a rewrite map file which maps the article titles to their IDs, eg:

The_best_eateries_in_town 35

The_best_cinemas_in_town 36

#etc

(that's be the syntax for mod_rewrite, I dunno how IIS7 handles these things, but know that it does handle them (from my 15sec worth of googling, just now)).

Rewrite maps scale pretty well, so having a mapping for each article - provided you don't have millions of them - would be fine.  You could regenerate this file from your DB periodically, or whenever an article is added / updated / deleted you could run an event handler that updates or recreates the map file.

Then it's just a matter of rewriting your URL from the human-friendly one to the one CF will expect.  It it was mod_rewrite that'd be something like:

RewriteMap title2ID txt:title2ID.map
RewriteRule ^/editorial/(.*)/ /editorial.cfm?id=${title2ID:$1}

IIS's rewriting engine seems to be all point-and-clicky-based, not .htaccess-based, so dunno how it effects the same thing, but that's pretty much what you want to do.

If you have too many articles to sensibly maintain a map file, then you're gonna need to include the article ID in the URL, thus:

http://whatever.com/editorial/The_best_eateries_in_town/35/

And use a rewrite to grab the "35".  This approach is probably easier, but makes for a slightly less friendly URL (although who really cares?  Who makes any judgements based on the URL... and that'll still be fine for SEO).

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 08, 2011 Apr 08, 2011

Copy link to clipboard

Copied

I've had need to use the IIS rewrite module recently, and it is very good. As Adam says it does have an interface, but all that does it help you create the web.config file - you can create this locally then just dump it in your web root if you don't have access to the server.

By far the most extensible and future-proof method is to include the Subject Id within the url somewhere so you don't have to map everything out. Look at this Amazon link:

  http://www.amazon.co.uk/Practical-Whispering-Threshold-picture-guides/dp/1872119670/ref=sr_1_1?ie=UTF8&qid=1302248856&sr=8-1

Spot the Id in there? 1872119670. They'll be ignoring everything else in that link (except url parameters) and just using the id to get the data from the database.

I've just tested a rule (I can't remember the exact regex so this one might be a bit shanty) which will allow rewriting of urls on a fairly basic level, but that needs no modifying when you add new first-level pages. The web.config looks like so:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="GenericSubjectId">
                    <match url="^(\w*)/([0-9]+)?/(.*?)/?$" />
                    <action type="Rewrite" url="/{R:1}.cfm?SubjectId={R:2}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

What it actually does is matches any url that starts with a word, then a forward slash, then a numeric id, then ignores the rest. This means that from the back of this rule, if I create a link to, say:

  /horses/938734/my_biggest_horse_ever/something/pics

Then it actually requests the page "/horses.cfm?SubjectId=938734" from ColdFusion. Likewise, if I go to:

  /people/01812/muppets/family

Then I actually get served "/people.cfm?SubjectId=01812".

That's what I'd do if you're not going to be doing too much with subfolders, but even then you can just amend the rule accordingly. Quick-and-dirty one-time-only setup for basic url rewriting!

For. The. Win.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 08, 2011 Apr 08, 2011

Copy link to clipboard

Copied

Wow, thanks for all of the suggestions! My host does have the mod rewrite component on the server, but I was just thinking... let me know if this is a lame direction to go:

When creating an article (which comes from a file uploaded to the server), my client inputs the editorial title. What if I also have him type in a search engine-friendly name, like "Backyard-remodeling-made-easy" and then I add that to the url, like "websitename.com/article.cfm?Backyard-remodeling-made-easy&articleID=335"

Would that be the best of both worlds or would the search engines just giggle at a bad attempt to create a readable string for them?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 08, 2011 Apr 08, 2011

Copy link to clipboard

Copied

Search engines haven't given a sh!t about what's in the URL for about ten years.

It's just pedantic humans with SEO jobs you need to placate.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 08, 2011 Apr 08, 2011

Copy link to clipboard

Copied

Then why all the hubbub over readable url's? Is it also to placate the users?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 10, 2011 Apr 10, 2011

Copy link to clipboard

Copied

Because if SEO experts said "there's nothing mysterious about it, I don't actually know anything more about the vagaries of Google than you do, just use common sense"... well... then... there'd be no SEO experts would there?

If Douglas Adams had been writing HGttG these days, SEO experts would be boarding the Golgafrinchan B-Ark alongside the hairdressers & those people who clean telephone receivers...

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 10, 2011 Apr 10, 2011

Copy link to clipboard

Copied

+1 @ Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 11, 2011 Apr 11, 2011

Copy link to clipboard

Copied

Adam is right.  URL formats don't make any difference to Search Engines.  However, readable URLs are still preferable.  If I am searching for 'Round widget by brand X in red', I am more likely to click on "www.domain.com/round-widget-brand-x-red" than "www.domain.com/viewItem.cfm?id=12345"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 11, 2011 Apr 11, 2011

Copy link to clipboard

Copied

Adam, can you cite that information?  I'd love to have some evidence to show anyone that Google (or any other search engine) does not look at the URL.

Jason

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 12, 2011 Apr 12, 2011

Copy link to clipboard

Copied

LATEST

No, I don't have anything specific, sorry: just random reading, non-scientific analysis of URL indexing & from conversations about SEO stuff from people in the queue waiting to board the B-Ark 😉

The resounding impression I get is that the most influential consideration - by a long march - is simply to have documents that contain information about the topic one wants to be found in a search on that given topic.  Crazy.  The influence the URL is going to have on this is minimal.

There seemed to be a real consideration as to URL construction years and years ago, and the impression I get is that this has kind of "stuck" in people's minds as being a consideration, despite the issue being one of locating & indexing the document in the first place, not how pretty the URL is.

I think "nice" URLs are a reasonable consideration as far as "actual people" are concerned: http://help.adobe.com/CFML/cfabort/ is going to be far more memorable than http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7fde.html for example, but it would be churlish of a search engine to consider http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7fde.html to be "better" than http://help.adobe.com/index.php?lang=en_US&product=ColdFusion&version=9.0&tag=cfabort.

It would be interesting to see if an SEO "expert" could come up with some evidence to refute this.  But, of course... they don't really know, do they? No.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation