Forum Moderators: phranque
Currently I have the following *pertinent* mod_rewrite rules:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=35]
RewriteRule ^page/?([0-9]{1,})/?$ /index.php?&paged=$1 [QSA,L]
RewriteRule ^comments/page/?([0-9]{1,})/?$ /index.php?&paged=$1 [QSA,L]
RewriteRule ^search/(.+)/page/?([0-9]{1,})/?$ /index.php?s=$1&paged=$2 [QSA,L]
RewriteRule ^search/(.+)/?$ /index.php?s=$1 [QSA,L]
RewriteRule ^archives/category/(.+)/page/?([0-9]{1,})/?$ /index.php?category_name=$1&paged=$2 [QSA,L]
RewriteRule ^archives/category/(.+)/?$ /index.php?category_name=$1 [QSA,L]
RewriteRule ^archives/author/([^/]+)/page/?([0-9]{1,})/?$ /index.php?author_name=$1&paged=$2 [QSA,L]
RewriteRule ^archives/author/([^/]+)/?$ /index.php?author_name=$1 [QSA,L]
RewriteRule ^archives/([0-9]{4})/page/?([0-9]{1,})/?$ /index.php?year=$1&paged=$2 [QSA,L]
RewriteRule ^archives/([0-9]{4})/?$ /index.php?year=$1 [QSA,L]
RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/page/?([0-9]{1,})/?$ /index.php?year=$1&monthnum=$2&paged=$3 [QSA,L]
RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/?$ /index.php?year=$1&monthnum=$2 [QSA,L]
RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/page/?([0-9]{1,})/?$ /index.php?year=$1&monthnum=$2&day=$3&paged=$4 [QSA,L]
RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$ /index.php?year=$1&monthnum=$2&day=$3 [QSA,L]
RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/page/?([0-9]{1,})/?$ /index.php?year=$1&monthnum=$2&day=$3&name=$4&paged=$5 [QSA,L]
RewriteRule ^archives/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)/?([0-9]+)?/?$ /index.php?year=$1&monthnum=$2&day=$3&name=$4&page=$5 [QSA,L]
what I have been experimenting with is reversing the chronological display of items. I can do this successfully but doing so requires appending a query to the end of the url, ie,
this is an actual example of something that works:
http://www.domain.com/archives/category/bleh/?order=asc My first goal would be to add another rule so that I could continue to maintain my cruft free urls, sans,
http://www.domain.com/archives/category/bleh/asc This alone is simple enough, I assume, but along with the other thing I have going, not so simple.
I have a clickable paged navigation system in place and given the above url, the subsequent navigation system that WAS producing cruftless uris now outputs:
http://www.domain.com/archives/category/bleh/?order=asc&paged=2 since the rewrite rules no longer match, obviously.
Additionally, the potential for this type of URI exists:
http://www.domain.com/archives/category/bleh/page/2/?order=asc which would be the result of someone changing the order AFTER having used the paged navigation. (the opposite of the example above)
I guess my starter question is this:
Is there a simple mod_rewrite solution to rewriting the 2 potential query options, so that my paged navigation system doesnt break, and so that I can continue to maintain my cruft free urls?
I apologize if this is confusing. :) Ive tried my best to explain.
After sorting all that, then it's simply a matter of making your rules recognize the (new) URLs defined by/on your pages and rewrite them properly to the script(s).
Also, be sure to completely flush your browser cache after any change to your rules. If a previously-cached URL is requested, your browser will serve it from cache, and no request will be sent to your server. In that case, your rewriterules cannot have any effect.
Jim