Goal:
301 redirect all requests for files in an old folder to one file in another folder using htaccess. That is: /forum/everypossiblefile –> /faq/index
Should be a very easy to find fix. 1) not so easy to find. 2) found two solutions that work…unless there is a “?” in the url. About 70% of the 1000 or so urls in our defunct forum had “?” somewhere. Thus,
/forum/index.php redirects correctly to
/faq/
/forum/viewforum.php?f=5 redirects to the made up URL
/faq/?f=5
Oddly, perhaps because of the same or other magical quality of “?” in an URL that is causing the problem, all variations of /faq/?whatever resolve correctly to the one target file at /faq/index.htm.
We don’t want to just call this good, because besides readers it’s mainly robots we are trying to redirect.
Thank you for this quick response! It’s almost 2 am here, so I’m reluctant to try this (and maybe break the whole site just before going to bed).
Just to be sure I’ve got the syntax correct, would this be it?
what does Options +Symlinks -MultiViews do? Is it necessary?
ReWrite engine is already turned on earlier in the page…leave this out, or keep turning it on over and over again for each of these commands (there are several similar ones)
An earlier poster said the absolute link did the trick for them…any reason to have it something else vs absolute?
The “problem” is that query strings are handled separately from the {REQUEST_URI} string which RewriteRules operate on. Please note that the “?” character is reserved in order to denote the separation from the URI and query string.
Rémon’s solution of stripping the query string by redirecting to a URI with a trailing ? will DELETE any pre-existing query string which would otherwise be automatically passed through. If you need to create a new key/value pair in your existing query string (which you’re not doing here), you will need the QSA (query string appended) flag.
Simple problem, simple solution.
As for your questions:
[indent]Detail questions–
what does Options +Symlinks -MultiViews do? Is it necessary?
Those should already be set in the server’s httpd.conf file but they are necessary for mod_rewrite to work. Remove them to test whether your host is “on the ball” or not - you can always replace them.
ReWrite engine is already turned on earlier in the page…leave this out, or keep turning it on over and over again for each of these commands (there are several similar ones)
mod_rewrite can be put in a “comment mode” using RewriteEngine off and returned with RewriteEngine on. It’s simply considered “good form” to start your mod_rewrite code with RewriteEngine on to ensure that it’s not been put in comment mode elsewhere.
An earlier poster said the absolute link did the trick for them…any reason to have it something else vs absolute?
It should make NO difference as mod_rewrite will operate on the Apache variables separately.
[/indent]
You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It’s helped may members and should help you, too.
I appreciate your help very much yet am in far enough over my head that I can’t understand much of what I’m sure is a helpful response that contains the answer to my issue.
I tried both
Options +Symlinks -MultiViews
RewriteEngine On
RewriteRule ^forum/(.*)$ /faq/? [L,R=301]
and
Options +Symlinks -MultiViews
RewriteEngine On
RewriteRule ^/oasisdesign.net/forum/(.*)$ http:// oasisdesign.net/faq/ [R=301,L]
and what I got was basically the comic book not good result, which was this for every single page on the site (ok, two or three of the outdated URLs, the faq and the home page.).
Is it possible to tell from the code I’ve posted above what went wrong, or more importantly, what would work?
[I]Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@oasisdesign.net and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.[/I]
I have successfully added a bunch of other stuff to the .htaccess file that has been functioning well. I put a copy of it here temporarily.