Most of my URL is fine thanks to Wordpress %postname% permalinks.
I would still like to change few query strings like ?edit= when editing post and ?updated=true if you submit your edit.
Could anyone give me a fast example with few comments which I could use to work my way up?
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
// I have no idea what comes here
</IfModule>
1) www.mywebsite.com/post-template/?edit=3242 <-- number is post ID
How to show only post ID after / OR replace ?edit= with word "potatoe" for example?
2) www.mywebsite.com/post-template/?updated=true <-- I have no idea how to change that, no ID's or anything
How to replace ?updated=true with word "carrot" for example?
I usually go grazy and start testing but I read that errors in .htaccess can cause some serious things.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^edit/(.*)$ theprocess.php?edit=$1 [L]
RewriteRule ^edit/(.*)/submitit$ theprocess.php?edit=$1&updated=true [L]
</IfModule>
The above is a sample for you to start (assuming the php file you're working with is called theprocess.php).
You will want to look into regular expressions because you'll use a lot of them with RewriteRules. The important thing is $1
will be replaced with the actual value in ()
which in this case is .*
meaning "match anything" at that point. So in the examples, if one types http://example.com/edit/123
then whats being processed is theprocess.php?edit=123