Forum Moderators: phranque
RewriteEngine on
RewriteRule ^/directory/file1.htm$ http://www.example.com/newdirectory/file1.htm?newdirectory/file3249861.htm [L,R=301]
RewriteRule ^/directory/file2.htm$ http://www.example.com/newdirectory/file2.htm?newdirectory/file3246731.htm [L,R=301]
Any help is so very much appreciated!
Jim
If your intent is to replace the URL shown by search engines in their results listings, then use the redirect. However, if your intent is to simply serve the content from the filepath /newdirectory/file2.htm?newdirectory/file3246731.htm when the URL http://www.example.com/directory/file2.htm is requested by a client, then use the internal rewrite syntax instead.
Also, note that any literal periods in regex patterns must be escaped with a preceding backslash slash. If the periods are not escaped, they are interpreted as regex tokens meaning, "match any single character." So, your pattern should likely be "^file1\.htm$"
Jim
I'm trying to google info on different syntax for an internal re-write, other than what I've got and not having much luck. Do I just drop the R=301?
[edited by: vero at 2:02 am (utc) on Feb. 12, 2009]
See the Apache mod_rewrite documentation on syntax differences between external redirect and internal rewrite. Also, there are dozens of examples posted here in this forum every day (and I always try to concisely comment my code)... :)
Jim