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

Regex to rewrite urls

Guest
Feb 08, 2010 Feb 08, 2010

I've been searching all over google and these forums and kind of have an understanding on how to do this, but i just can't figure this out with regex. I know there is a way to rewrite urls using mod_rewrite to make coldfusion urls seo friendly but it just doesn't work for me lol....

This is the url i currently have:

domain.com?type=soccer&zip=33141

I'm trying to get it to be

domain.com/soccer/33141

And then also have all the links within the page be re-written as well so when the spiders look at it, all the links look like:

domain.com/soccer/33141 or domain.com/basketball/33139

664
Translate
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
Advisor ,
Feb 09, 2010 Feb 09, 2010

You might have better luck with this question on an Apache specific forum, if Apache is your web server.  AFAIK ColdFusion does not handle URL re-writing; this is handled by the web server (Apache or IIS).

Translate
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
Engaged ,
Feb 10, 2010 Feb 10, 2010

Have you looked into the Ionics Isapi Rewrite Filter?  It's free and pretty simple to use.  Of course, you need to have acess to your server in order to use it...but other than that, I've had nice luck with it.

Translate
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
Participant ,
Feb 11, 2010 Feb 11, 2010

You can use regular expressions \&(.)*= and \?(.)*= as shown below:

<cfset myURL = "domain.com?type=soccer&zip=33141" />

<cfset myURL = "#REReplaceNoCase('#myURL#','\&(.)*=','/')#" />

<cfset myURL = "#REReplaceNoCase('#myURL#','\?(.)*=','/')#" />

<p><cfoutput>#myURL#</cfoutput></p>

Translate
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
Guest
Feb 11, 2010 Feb 11, 2010
LATEST

Thank you all for your help, that wax exaclty what i was looking for.

Translate
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