Forum Moderators: phranque
I recently managed to rewrite my sites' dynamic urls to statics using JD Morgan's guide.
This works using...
rewriteRule ^c-([^/]+)/?.htm$ /categories.php?cat=$1 [L]
rewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /categories\.php\?cat=([^\ ]+)\ HTTP/
rewriteRule ^categories\.php$ [mysite.co.uk...] [R=301,L]
As a rule, this is absolutely fine. However in some instances, i would like to rewrite individual url rewrites again (rewrite a url twice).
In doing so, I would be rewriting the newly generated url:
[mysite.co.uk...]
to
[mysite.co.uk...]
I have attempted various things but to no avail.
Has anybody got any suggestions? All ideas would be greatly appreciated.
Cheers
Therefore, you can't "rewrite" the URL again, because the current HTTP transaction has ended. Nothing will happen until the client sends a new request (probably using the new URL you sent to it). When the client re-issues the request, you will see the address bar change to this new URL.
I also don't know why you want to do a redirect there, as it doubles the load on your server, doubles the visitors' page load times, and 'exposes' your SE-unfriendly script URLs.
However, regardless of that, don't rewrite twice. Instead, put the more-specific rewriterules first, so that your 'special' URLs are rewritten to the correct URL all-at-once in a single step. Then let your current rule pick up and rewrite/redirect the remaining URLs, as desired.
For the sake of completeness, an internal rewrite changes only the server filepath associated with a requested URL, and occurs completely within the server and within the context of the current HTTP transaction; The client will be unaware that any change has taken place.
Jim