Forum Moderators: phranque
I need your help..
how to redirect folder & parameter to new location?
my current address is like this:
[search.example.com...]
i want to rewrite/redirect it to
[search.example.com...]
Thank You.
If it is for a rewrite then omit the domain name from the target and use just [L] on the end of the rule.
Whichever you use, you will also need a preceding RewriteCond that looks at QUERY_STRING values.
However, you need to make up your mind whether you want a rewrite or a redirect. They are different things, though their syntax is very similar.
Which URL do you want users to 'see' and 'use' on the web?
What is the 'real' filepath for the content as stored on the server?
Thanks for your response.
What i want to do is move my current folder and all its data named "find" to new location named "search". And visitors that go to old location (spider also counts) needs to be redirected to new location.
i have made a .htaccess to be placed in the "find" folder
# allow all except those indicated here
RewriteEngine on
Rewritebase /
RewriteCond %{QUERY_STRING} kw=(.*)
RewriteRule .* http://test.example.com/search?term=%1&subid=old [R=301,L]
can u check wheter my code is OK for this purpose?
Thanks
Obviously my question was not very clear.
Do you want to change the URL that users on the web use to access the content? Or are you physically moving the content around inside the server?
However, if you are moving content around inside the server, you do NOT have to change the URLs that users use to access that content. That's what a rewrite is for.
It is not a good idea to change the URL that users use to access a resource; "Cool URIs don't change".
Which URL do you want users to 'see' and 'use' on the web?
What is the 'real' filepath for the content as stored on the server?
i have many indexed page at my old folder & i dont want lose that indexed pages because of moving my current folder.
my current index.php is in "find" folder rite now..
because i want to change to new turnkey script (that will be placed in "search" folder) so all URI will be changed.
P.S. Sorry english is not my primary language
You do not have to change the URI just because the file location changes. Simply map (rewrite) the "find" URI to the "search" filepath.
In /find/.htaccess :
RewriteEngine on
#
RewriteCond %{QUERY_STRING} kw=(.*)
RewriteRule .* /search?term=%1&subid=old [L]
[edited by: jdMorgan at 2:30 am (utc) on Feb. 26, 2009]
RewriteCond %{QUERY_STRING} &?kw=([^&]+)&?
RewriteRule ^$ /?term=%1&subid=old [L] But why have parameters in the URL if you are using a rewrite? You have parameters in the filepath, but you don't need to have them in the URL if you are using a rewrite. You could use
example.com/keyword extensionless URLs instead.