Expanding friendly url, mod rewrite


I am using modx, which is a cms system. It has a friendly url-option and uses a .htaccess like this.

# The Friendly URLs part RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

If makes the url look like: mysite.com/about and mysite.com/about/contact

I'd like to expand this .htaccess, so I can write myste.com/about/2 without the page 2 actually existing. I'd like to have the ability to access this in a get-variable. Can this be done? I have no knowledge at this area whatsoever.


You <em>could</em> do this in your .htaccess, but a better way might be to create a plugin that fires on the OnPageNotFound event.

myste.com/about/2 does not exist so it will trigger your plugin which will run before sending the user to the 404 page. In this case, you can can split the /2 from the end of the url and use it to pull in your data or send the user to a different page instead of going to 404.

Does that make sense? It's a bit difficult to contribute more without knowing exactly what you want to do :)


  • Why is my htaccess rule not rewriting the url
  • url rewrite not working .htaccess
  • Mod_rewrite handling extra get variables (QSA not working)
  • “Internal Server Error” with Hello World Python App
  • How ignore any files using HHVM proxygen rewrite rules?
  • How do I use cURL & PHP to spoof the referrer?
  • add new field to form with rvest
  • Can I customize a Jackson ObjectMapper by adding a module?
  • Change Divider Color Android DatePicker Dialog
  • joomla! 1.5.26 and “You are currently logged in to the private area of this site”
  • Google Bigquery Command Line Return Limit
  • Nginx rewrite equivalent to Apache RewriteRule that converts URL params into QueryString key/value p
  • FragmentActivity with a Fragment Containing a MapView
  • Many to many relationship core data query for specific collection
  • SSL client cert authentication for only some URLs?
  • apply a javascript function to draggable copy
  • Android changing fragment order inside FragmentPagerAdapter
  • Create DicomImage from scratch using Dcmtk
  • Groovy: Unexpected token “:”
  • Limiting recursion to certain level - Duplicate rows
  • Is there a way to do normal logging with EureakLog?
  • How to set ini file attributes during an Inno install
  • Setting up SourceTree to merge unity3d scenes with UnityYAMLMerge
  • Email format validation in mvc3 view
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • Can Jackson SerializationFeature be overridden per field or class?
  • How to add date and time under each post in guestbook in google app engine
  • Upload files with Ajax and Jquery
  • Do I've to free mysql result after storing it?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Apache 2.4 - remove | delete | uninstall
  • A cron job substitute?
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • json Serialization in asp
  • Proper way to use connect-multiparty with express.js?
  • Benchmarking RAM performance - UWP and C#
  • coudnt use logback because of log4j
  • Conditional In-Line CSS for IE and Others?