Generic Search Engine Safe URL's on Apache
A while back someone asked about implementing generic search engine safe url's with Apache's mod_rewrite module. I came up with a solution but I didn't have a chance to test it until recently. What I mean by generic are URL's such as:
site.com/page.cfm/id/123 and NOT
site.com/page/132, which would be specific to just one CFM template. So we only need to create the rules once. This is nice for sites with lots of templates because you don't need to create a rule for each template. Here's what you need to add in your Apache config:
RewriteEngine On #with one url param RewriteRule ^/(.*)\.cfm/([^/]+)/([^/]+)$ /$1\.cfm?$2=$3 [NE] #two url params RewriteRule ^/(.*)\.cfm/([^/]+)/([^/]+)/([^/]+)/([^/]+)$ /$1\.cfm?$2=$3&$4=$5 [NE]
That code will work for up to two url variables, eg page.cfm/id/1/sort/price, if you need to support more you can just add additional rules. This can also work for php, jsp or whatever extension you want, just replace
cfm with your extension.
- Docker Container exited with code 137
- Why is my cron.daily script not running?
- Announcing FuseGuard Version 3
- CFSummit 2017
- Java Unlimited Strength Crypto Policy for Java 9 or 1.8.0_151
- Java 9 Security Enhancements
- Upcoming CFML Conferences in April 2017
- CFSummit 2016 Slides