Forum Moderators: phranque

Message Too Old, No Replies

rewriting/redirecting all external links to a new link - I'm a newbie

rewriting/redirecting all external links to my domain with.php=#*$!x

         

montreal06

10:46 am on May 25, 2012 (gmt 0)

10+ Year Member



Hello,

I am trying to rewrite all my external links on my site into a new URL.

For example:

external link: http://www.example.com/home/news.php?id=31155

should be

http://www.example.com/bt2/wp-content/plugins/topbar-plugin/topbar.php?url=http%3A%2F%2Fwww.asianewsnet.net%2Fhome%2Fnews.php%3Fid%3D31155

All of the external links will have the format http://www.example.com/bt2/wp-content/plugins/topbar-plugin/topbar.php?url=examplexx

Note: I want to make an exception that www.cnn.com be excluded from a rewrite and redirect rule

Thanks,
Mike

[edited by: montreal06 at 11:00 am (utc) on May 25, 2012]

[edited by: incrediBILL at 12:42 pm (utc) on May 25, 2012]
[edit reason] fixed URLS, use Example.com [/edit]

g1smd

10:56 am on May 25, 2012 (gmt 0)

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



Please edit your post following the instructions in [webmasterworld.com...]

There are 80 000 threads in this forum, and at least 10 000 of them cover the code you are talking about.

After reviewing those, please post your code for discussion.

montreal06

11:06 am on May 25, 2012 (gmt 0)

10+ Year Member



I tried looking for this using keywords external redirect or external rewrite, but I did not get the results I wanted

lucy24

8:56 pm on May 25, 2012 (gmt 0)

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



Well, you don't always get the results you want. But if you try sometimes you just might find you get the results you need.

You can constrain the search to /apache/ to narrow it down. You don't want an external anything; "external rewrite" in particular is a contradiction in terms unless you're messing about with proxies. (My advice: don't.) Sometimes Apache says "internal redirect" where we say "rewrite" alone.

Why does the query string need to contain the complete URL? Seems like it would be more efficient to make your php page look it up when the request gets there, instead of shoving it all into htaccess. There's obviously no way to make htaccess generate text from numbers, so it has to be either looked up or explicitly written out.