Forum Moderators: phranque

Message Too Old, No Replies

How to do compliant redirection?

         

toplisek

4:21 pm on Dec 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have issue that simple redirection does not work.
(like ?id=file1) How to edit the .htaccess directly to insert the conditions (in this case, the reuqested URL) and the rule?

g1smd

5:14 pm on Dec 21, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That's far too vague a question.

Let's see a small chunk of the code you are talking about.

I might assume you're talking about RewriteRule or something. To check query string parameter values, you need a RewriteCond that looks at QUERY_STRING.

toplisek

1:35 pm on Dec 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Sorry if I was not so clear.
Please find code as following:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.com
RewriteRule ^(.*)$ [mydomain.com...] [R=permanent,L]
Options +FollowSymlinks

# Redirects URL
Redirect permanent /en-GB/allservices/index.php?id=myID1 [mydomain.com...]

g1smd

3:23 pm on Dec 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There's problems if you use Redirect and RewriteRule in the same file.

The order the rules are processed is indeterminate, as rules are processed in 'per module' order, not in the order they appear on the page.

That is, all rules from Mod_Alias might be processed before all those from Mod_Rewrite - or maybe it is the other way round.

Stick with RewriteRule for all of your rules to avoid that problem, and order the rules from most specific to least specific.

toplisek

5:55 pm on Dec 22, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can you tell me please code with rewrite in correct way to redirect?

jdMorgan

1:12 am on Dec 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As stated in our Forum Charter, we ask that you please do not request the contributors here to write your code for you -- If it's important to you, then please try to code it yourself and take the opportunity to learn something new.

That said, Merry Christmas:


Options +FollowSymlinks
RewriteEngine On
#
RewriteCond %{QUERY_STRING} ^id=myID1$
RewriteRUle ^en-GB/allservices/index\.php$ http://www.example.com/mypage.php? [R=301,L]
#
RewriteCond %{HTTP_HOST} ^mydomain\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

Jim

toplisek

7:47 pm on Dec 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks

toplisek

8:20 am on Jan 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi,
I tested now.
I have issue that you used Page1 and Landing page.
Page1 is without ID in my case and Landing page has ID.
Landing page in your case is simple index.php but I have ID like index.php?id=mypage1 and Paga1 is simple page1.php

you put
RewriteRUle ^en-GB/allservices/index\.php$ http://www.example.com/mypage.php? [R=301,L]