Forum Moderators: phranque
Options +FollowSymLinks
RewriteEngine OnRewriteRule ^(.*)/(.*)/$ http://localhost/new/index.php?pagenum=$1&category=$2 [L]
[edited by: Dragosh at 7:36 am (utc) on Aug. 30, 2007]
RewriteRule ^([^/]+)/([^/]+)/?$ /new/index.php?pagenum=$1&category=$2 [L]
But it's possible that this description is the real problem:
But it should transform, for example http://localhost/new/index.php?pagenum=1&category=all to http://localhost/new/1/all
Mod_rewrite works on "incoming" URLs received by the server in the HTTP requests made by the client. It does not change URLs at all -- all it changes is the server filepath associated with a requested URL.
So if it is your intent to use mod rewrite to 'edit' the links on your pages, I'm afraid that won't work at all. It is the page which defines the URL, not the server. Mod_rewrite can only change the filepath to be used to serve the content for a requested page.
So, making 'friendly URLs' is a three-step process:
1) Change your links by editing the pages (or the script that produces your pages), to link to friendly URLs.
2) Add mod_rewrite code, so that the server can translate those friendly URLs, when requested, to the correct filepath for the requested page, or to invoke your script to generate the requested page.
3) (Optional) Add a mod_rewrite rule so that any direct client requests for the 'unfriendly' URL are externally redirected to the 'friendly' URL.
More info here [webmasterworld.com].
Jim