Forum Moderators: phranque
I've had php scripts running on my site which created URL's that had a structure where there were 8 or 9 adaptations of a page that changed (http://foo.com/directory/filename.html) by inserting a simple: "1thing.php?a=" before an existing folder and filename and presented many variations on those pages:
[foo.com...] X 900 filenames
[foo.com...] X 900 filenames
[foo.com...] X 900 filenames
There were about 8 of these variations.
I've deleted those scripts and want to redirect *some* of them to flat HTML pages, but there are about 900 possible variations in folder and filenames in a flat html site. That means there are about 900 variations for EACH of those 8 scripts totaling 7200 variations which I've deleted from my server.
Is it possible to rewrite this to redirect in a way that sends visitors from these:
to these:
I'd like to have this apply only specific filenames and not necessarily all 900 of them. In other words, I'm only creating a limited number of flat html pages that I will redirect to, so will manually list only those files I want to redirect to and let the rest fail to 404 errors.
(I have a current rewrite rule to force the non-www version of my url, just like the example given I mention this because I've seen several rewrites forcing www in the URL and I don't want to force to www.)
If I take your example URLs literally, then the 'mapping' of old to new URLs could be done with something like:
RewriteCond %{QUERY_STRING} &?a=([^.]+)\.html&?
RewriteCond %{DOCUMENT_ROOT}/%1-$1.html -f
RewriteRule ^([^./]+)\.php$ http://example.com/%1-$1.html [R=301,L]
Jim