Create custom url extensions with php

It is been an extremely long time since I have posted due to a whole lot going on. I used to be an avid user of Commission Junction but again, I have been way to busy to even login to CJ in a couple of years.

That being said, I am just logging into CJ for the first time in a long time. I notice that their page extensions no longer end in cfm or whatever but now end in cj. For you php users, you can do the very same thing with just a little work.

First off, if you use WordPress -> Simply change the permalinks to /%postname%.newextension. See how our url extensions are now .pig? 😀

For custom scripts, you can simply do this with mod rewrite on the server. Open the root .htaccess file or create one if not created. On my custom scripts, I usually rewrite the url from index.php?task=view&id=1 to id-Name_Of_Entry.html.

In .htaccess, I rewrite this by using the following command:
RewriteRule ^([0-9]+)-([a-zA-Z0-9?-]+) index.php?task=view&id=$1&name=$2 [L]

Simply change the command to:
RewriteRule ^blog/([0-9]+)-([a-zA-Z0-9?-]+).newextension index.php?task=view&id=$1&name=$2 [L]

Finally, I would update my php file that handles rewriting the links to add the new extension.

If you want to try something new, give this a try!



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.