Msg#: 4015106 posted 8:21 pm on Oct 28, 2009 (gmt 0)
A rewrite does not 'generate' a new URL. URLs are defined by the URLs in the links on your pages.
Change those links to show the URL that you want users to see and use. Then construct a RewriteRule that accepts those URL requests and fetches an alternative file and path inside the server.
You now also need two redirects. One accepts URL requests with parameters. The other accepts URL requests for the old URLs. Both redirect to the new URL format. This tidies up any traffic coming from other sites, as well as forcing searcheingines to update their index.
Msg#: 4015106 posted 3:03 am on Oct 29, 2009 (gmt 0)
A couple of points to clarify and make things easier for you (and everyone)...
You are apparently confusing URLs with filepaths, misunderstand the 'direction' of RewriteRule's action, and therefore probably also misunderstand both *when* mod_rewrite takes effect, and also what it does when it acts.
Rewrites an incoming client-requested URL of "example.com/directory/<value>/" to an internal serverfilepath of "/pagename.php?var=<value>"
So, it is not 'generating' anything at all, it is merely 'connecting' the static-looking, SEO-friendly URL to the correct server filepath, and moving the 'subdirectory' name into the query string variable "var", where your "pagename.php" script can access it as a "GET variable."
The URLs are defined in the <a href="new/"> links in your pages' HTML code -- That is where they are 'generated' -- not by some 'magic' of mod_rewrite.
Your rule could be more-efficiently coded as either
RewriteRule ^directory/([^/]+)/$ directory/pagename.php?var=$1 [L] -or- RewriteRule ^directory/(.+)/$ directory/pagename.php?var=$1 [L] depending on whether you want to accept slashes within "var".
So all that said, please post an example of your best-effort at coding the old-to-new URL redirects, as a basis for discussion.