mod_rewrite external links issue (wordpress) - mod-rewrite

i have a redirect.php and a link and it doesn't work in WORDPRESS.
i expect when i click the "hello" link on my site, it goes to redirect.php, the user sees the spinner for 5 secs, and the users exits my site to hello.com
it looks like there is something wrong with mod_rewrite i'm unable to solve
i'd really appreciate a very detailed answers. i am very junior
this what i have.
1.- I have an external link in my homepage:
Hello
2.- In redirect.php, i have:
<html>
<head>
...
<meta http-equiv="refresh" content="5;url=<?php echo $_GET['link'];?>" />
...
</head>
<body>
<h1>You are leaving my site!</h1>
<img src="/images/spinner.gif" alt="spinner" />
</body>
</html>

The link <a href="http://redirect.php?... is incorrect. This should most likely be <a href="/redirect.php?... or any subdirectory on your server.
You should also include the protocol in your link parameter or prepend it in your meta tag. Also make sure to HTML encode the link in your meta tag and to properly URL encode the domain name in your link parameter.
So, change the link to:
Hello
if you have the redirect.php file in the root of your website. And change the meta tag to:
<meta http-equiv="refresh" content="5;url=<?php echo htmlentities($_GET['link'], ENT_QUOTES,);?>" />
And you might want to do some validation on the validity of the link parameter and you possibly also want to check the referrer URL ($_SERVER('HTTP_REFERER')) to make sure you only perform redirects for links from your own website (i.e. don't create an open redirect vulnerability).

Related

YOURLS Short URL to Domain

Morning - I'd like to redirect my short url ie: https://sho.rt to my domain https://short.com
At the moment my sho.rt is pointing at the admin panel. Could you please advise as to how I'd redirect.
Thank you
You will need to build an index.php file that sits in the yourls top level directory. A simple example of how to redirect using html is.
<html>
<head>
<title>Your Site Title</title>
<script>
window.location.replace("https://www.yourwebsite.com");
</script>
</head>
<body>
<h2>If you are not automatically redirected in 5 seconds, Click Here</h2>
</body>
</html>

HTML META REDIRECT to old URL

I just wanted to redirect from e.g. www.example.com/example to another URL.
I tested it with this index.html in example.com/example and it looked like this:
<html>
<head>
<title>TITLE</title>
<meta http-equiv="refresh" content="0; url=http://sample.org/sample">
</head>
Goto to URL http://sample.org/sample
manually.
</html>
It worked just fine. Then I changed the "http://sample.org/sample" URL to the URL I wanted to redirect to.
But there occures the problem. It still redirects the example.com/example to sample.org/sample and not the actual one.
I tried to clear the cash, history and cookies in Firefox and did a DNS-Flush with "ipconfig /flushdns".
I also deleted the folder example and created it new. But nothing helps.
When I'm accessing example.com/example/index.html it redirects to the URL I want to. But if I'm accessing example.com/example it still redirects to the unwanted sample.org/sample.
Any glues how to fix this?
I just figured out that the proxy in our company also does have a cache. I tested it outside of our company network and it worked just fine. So this is fixed ;)

Issue with Open Graph Debugger not seeing og:url correctly

I'm having an issue trying to verify my Open Graph object. The debugger says:
"There was an error in fetching the object at URL 'http://digiarmy.com/ogItem.php?id=3', or one of the the URLs specified via a redirect or the 'og:url' property including one of http://www.digiarmy.com/ogItem.php?id=3."
Yet in the section titled Raw Open Graph Document Information I see this:
<meta property="og:url" content="http://www.digiarmy.com/ogItem.php?id=3" />
Am I just missing something or is something not working? I did the Cookie Recipe tutorial and it works fine.
Remove the www from the url meta tag since you are redirecting www to non-www.
try adding
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://ogp.me/ns#">
above the head of your doc. If this does not solve the issue, you may wanna remove any redirects you have in DNS for that page.

Facebook button for Ajax Pages, how to implement and verify that it works

I wanted to know how can I use Facebook Like button on my Ajax web application, that will capture changes in the Open Graph tags for both the og:title and the og:url. I already created a Facebook app and got an API ID.
What I want to know is the code that I need to put on my website in order for Facebook to capture the changes that I've made to the meta tags which contains that title and url information (ie. og:title, og:url).
I followed the instructions on Facebook without success. Furthermore, I want to know how can I locally test the Like button to see that it grabs the data from the Open Graph tags properly.
Also worth mentioning that I've a JQuery code that automatically alters the Open Graph meta tags to include the relevant information for the current Ajax changed page.
Thanks.
You will need to have a separate url for each different page that you want to allow people to like. I would recommend actually pointing the like button to the physical pages you're trying to return via the og:url tag. To refresh the data that Facebook stores about a given url, pass that url into the linter at http://developers.facebook.com/tools/lint.
i created a rotator file for facebook share on my dynamic ajax website.
rotator.asp code sample:
<html>
<% lang=request("lang")
id=request("id")
..some sql to get data...
ogTitle=....
ogImage=....
originalUrl=....
%>
<head>
<meta property="og:title" content="<%=ogTitle%>" />
<meta property="og:image" content="<%=ogImage%>" />
.....
......
<meta http-equiv="refresh" content="0; url=<%=origialUrl%>" />
//dont use redirect.. facebook dont allow 302...
</head>
<body></body>
</html>
for example xxx.com/#!/en/153 page will share xxx.com/rotator.asp?lang=en&id=153

How can I redirect my domain to a different page or directory?

Please suggest a method other than use of .htaccess..
It really is homework-due-day today.
Theres httpd.conf (apache)
http://httpd.apache.org/docs/1.3/configuring.html
Or, forcing an "Error 301 - redirect".
Or, you could put a meta-refresh in your webpage redirecting to the new webpage.
e.g.
<meta http-equiv="REFRESH" content="0;url=http://www.the-domain-you-want-to-redirect-to.com">
Or you could use javascript to force the redirect.
<script type="text/javascript">
window.location = "http://www.google.com/"
</script>
Then there are things like Reverse Proxy that could do what you wanted.
Depending on the technology and/or your access to the web server there are various options. In addition to the above you could use a server side code redirect e.g. in ASP.Net
Response.Redirect("http://www.google.co.uk")
I'm sure there are PHP and various other code alternatives to perform the same action.
You can do a client side redirect using an index.html and a META Refresh tag.
<html>
<head>
<meta http-equiv="refresh" content="0;url=http://www.mysite.com/MyDir/MyPage.html" />
</head>
</html>
http://en.wikipedia.org/wiki/Meta_refresh
Implementation-agnostic:
The following status codes can be used in a web server response:
301 Moved Permanently
302 Found
If you don't have access to a decent web server, try the Javascript
or Meta-Tag methods above.
Bonus: another implementation-specific advice, using Hunchentoot:
(redirect "http://otherhost/otherpath")

Resources