Forum Moderators: phranque
redirect 301 /page1.htm [domain.com...]
As a final resort, you can use RedirectMatch in mod_alias or a mod_rewrite ruleset to remove the character.
Jim
my URL redirect code is;
redirect 301 /page1.htm [mydomain.com...]
if i remove the "?" in
"redirect 301 /page1.htm [mydomain.com...]
the resulting URL becomes [mydomain.com...] which is my original URL that i have rewrited to [mydomain.com...]
Is there any possible solution to solve this problem?
Redirect directive [httpd.apache.org]Syntax: Redirect [status] URL-path URL
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Base
Module: mod_alias
Compatibility: The directory and .htaccess context's are only available in versions 1.1 and later. The status argument is only available in Apache 1.2 or later.The Redirect directive maps an old URL into a new one. The new URL is returned to the client which attempts to fetch it again with the new address. URL-path a (%-decoded) path; any requests for documents beginning with this path will be returned a redirect error to a new (%-encoded) URL beginning with URL.
Example:
Redirect /service [foo2.bar.com...]If the client requests htp://myserver/service/foo.txt, it will be told to access htp://foo2.bar.com/service/foo.txt instead.
I would say the simple solution is to use mod_rewrite, rather than mod_alias.
RewriteEngine On
RewriteRule ^/page1\.htm$ /newpage [R=301,L]
Give that a try and see if it helps.
For use in .htaccess, delete the leading slash from the RewriteRule Pattern. You also may have to add the Options directive shown.
Options +FollowSymLinks
RewriteEngine On
RewriteRule [b]^p[/b]age1\.htm$ /newpage [R=301,L]
Well, it cannot appear "by magic", so some code, somewhere is adding the "?". It is either in your .htaccess file, or the server is mis-configured; Ask your host.
Jim
One other thought crossed my mind, though. It is possible that the "?" is being added due to content negotiation. If that is the the case, then the single line:
Options -MultiViews
Jim
1. if i redirect "page1.htm" to "newpage" using the following code,
redirect 301 /page1.htm [domain.com...]
the resulting URL becomes
[domain.com...] which is my problem earlier.
2. Now ro remove the "?cat=1", redirect it again using,
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /newpage\?cat=1\ HTTP/
RewriteRule ^dir/index\.php$ /newpage? [R=301,L]
I dont know what does "dir/index\.php" do, but it works.
3. My little problem here is that, i have so many redirects;
redirect 1: /dir/index.php?cat=1 -> /page1.htm (my old one)
redirect 2: /page1.htm -> /newpage?cat=1
redirect 3: /newpage?cat=1 -> /newpage
I dont think, Search engine bots will be happy for me. :(
Thnaks for the help guys.