Forum Moderators: phranque

Message Too Old, No Replies

Custom redirect in htaccess

redirect htaccess

         

sweet160

5:20 pm on Feb 17, 2012 (gmt 0)

10+ Year Member



Hi i would like to redirect with htaccess

http://www.mysite.com/administrator/index.php?option=com_modules&client=0


to

http://www.mysite.com/administrator/index.php


But i havent got an idea how to write the rule,

thank you very much....

g1smd

5:41 pm on Feb 17, 2012 (gmt 0)

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



Please at least have a go at starting the two lines of code, otherwise the preceding 80 000 threads with examples have all gone to waste...

sweet160

5:53 pm on Feb 17, 2012 (gmt 0)

10+ Year Member



RedirectMatch 301 http://www.mysite.com/administrator/index.php?option=com_modules&client=0(.*) http://www.mysite.com/administrator/$1


I have this but it doesnt work...

g1smd

5:55 pm on Feb 17, 2012 (gmt 0)

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



Pattern matching works only with the requested path. It cannot test the requested domain nor parameters.

RedirectMatch cannot be used when the request contains parameters. Use a RewriteRule to test the path and a RewriteCond to test QUERY_STRING or THE_REQUEST.

Use example.com in this forum to suppress auto-linking.

sweet160

6:16 pm on Feb 17, 2012 (gmt 0)

10+ Year Member



I really have to admit that this isnt my field but i am guessing something like:

RewriteCond %{REMOTE_HOST} !^.+\.administrator/index.php?option=com_modules&client=0$
RewriteRule ^(/~.+) http://www.example.com/administrator/$1 [R,L]

lucy24

10:47 pm on Feb 17, 2012 (gmt 0)

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



Guess a little more. REMOTE_HOST is the other person's domain name. You need to look at QUERY_STRING, among other things.

The Rule will always fail, because the body of an URL in mod_rewrite never begins with a / unless it was malformed to start with.

R by default means 302. Never use this unless you really do plan to stop redirecting within a few weeks.

Come to think of it, I don't remember seeing any discussion on what "temporary" means. Maybe there isn't a hard-and-fast rule other than "I won't be doing this forever".