How to transparently redirect media files from one website to another? - html

I have two domains, website1.com and website2.com.
website1.com contains data on it, let's say it's website1.com/picture.jpg.
website2.com is brand new, there's nothing on it, except index.html (though it's possible to put WordPress on it).
I want to transparently mask/redirect/rewrite website2.com over website1.com. So when a person tries to access website2.com/picture.jpg, they get the picture that is physically located on the address website1.com/picture.jpg instead of 404. I know it's possible to do a single-page redirect this way by editing website2.com's index.html:
<meta http-equiv="refresh" content="0; url=http://website1.com/" />
But it will only redirect a single page to a single page. What I want the server to do is to take the path /picture.jpg from website2.com that is nonexistent and automatically redirect it to website1.com/picture.jpg, no matter if it's /picture100.jpg, /pictures/picture.jpg, etc.
Is it possible to do that?

Related

Redirecting unless client has come from paypal

I'm trying to have the HTML code check where a client came from so they can only access this page through a link and we will say this link is from Paypal after purchase and if they don't go through Paypal they will be redirected to the home page of my website, in this case, is home.com (not really).
My Code:
if(!isset($_SERVER['HTTP_REFERER'])){
<meta http-equiv="Refresh" content="0; url='https://bypassdetected!'" />
header('location:../index.php');
exit;
You would need to check if the contents of HTTP_REFERER includes 'paypal.com', although this is a dumb sort of check since it's easily spoofed and accomplishes little of value
Regarding the action your code then takes, you can't combine HTTP header location redirects with HTML redirects, it's one or the other, but if you do try to send both, the headers have to be set before any body content
Redirecting over to PayPal should be avoided in general. You should switch to a PayPal integration that does not use any redirects at all, such as this one: https://developer.paypal.com/demo/checkout/#/pattern/client -- then, your site always stays loaded in the background, which is a far better modern web experience

How to redirect from a html page to a another html page which is on local disk

I am creating an appraisal application to accept apraisal for employees and store in the backend, The first page is a login page ,If user has successfully logged in it should redirect to another page which shows employees information but the catch here is that both pages are on local system ,as the browser runs in sandbox mode window.location is not working,I have tried many other similar options but still it doesn't work,I want to know can I use apache or some other server for this purpose.If yes what would be the way to do it
Use the meta-refresh keyword and supply a path.
somebody add an example, don't have one
I tried window.location.href() and got it to work
Here is the example redirection with meta tag.
<meta http-equiv="refresh" content="0;URL='http://bing.com/'" />

Calling Servlet from HTML

i want to call servlet everytime when an html page is loaded.In other words HTML page calls a servlet link automatically not via form.
For this am using below meta tag in html page,
<meta http-equiv="refresh" content="0; url=http://zerocool:8080/practice/WelcomeServlet?123">
Now when a user visits HTML page he gets redirected to servlet,and this servlet after analyzing the user redirects him back to the original HTML URL or someother URL depending upon valid and invalid user.
Now my question is,by adding above meta tag will the website be punished by google search engine or not in terms of SEO/ranking as user is redirected twice,1st to servlet and second back to html page.But all this happen very fast.
OR
You can suggest some alternate way to call servlet.
Actually servlet will be monitoring cookie in users browser to validate user
This way it is likely to end up in an infinitive loop which is extreme annoying for the user.
You should either use Ajax or apply an redesign. You can't protect a html page against users while allowing google to view it.
ONe way to protect pages is FIRST to check whether an user is logged in and if so show the protected page, otherwise collecting authorization data.

Hide the file name in the URL

what is the best method of hiding the file name in the URL from a developers side (who has no control over the server), for example if the site is www.123.co.za/contact.htm - i wan the user to only see www.123.co.za. an example of such can be seen here http://www.groupon.co.za
ways i know of is using one page and dynamically loading page content using ajax
the other is frames
(server options like mod_rewrite i cant use as i dnt have access to or control over the server)
They are using index pages. That means they have a page such as index.html, index.php, or index.aspx, etc. All you have to do is create a directory (for example, 'contact') and put a file named 'index.html' within that directory. Then you can view www.123.co.za/contact/index.html as www.123.co.za/contact. Note that your allowable index page names may vary. If index.* doesn't work for you, contact the host and ask (sometimes it's default.*).
The catch to this method is that your page is now viewable by at lest three URLS (www.123.co.za/contact, www.123.co.za/contact/, www.123.co.za/contact/index.html). This can hurt your site in search engines for you may get penalized for "duplicate" content. You could solve this issue with mod_rewrite but seeing as you can't use that, you can't prevent the aforementioned scenario.

HTML: should I add meta information to the forwarding php page?

I've to correct the google search title and summary for a website having the following code as home page:
<?php
header("Location:/mil/index.php");
?>
It forwards the user to another page. I know this is not good, but I was wondering how to quickly fix it.
If I add etc... to this page, is enough ? Is google grabbing the information from this page ?
Or is it grabbing from the website pages and bypassing this page ?
thanks
At the moment you are performing a 302 redirect, which tells Google that content found at the first page has temporarily moved to the second. Because of this, Google will not update it's index, and will continue to treat the first page as the important one. If it's empty, then that is no good for your search rankings. Do this instead:
header ('HTTP/1.1 301 Moved Permanently');
header ("Location:/mil/index.php");
A 301 redirect tells Google that the content has permanently moved to the new location, and they will update their index appropriately.
If this is a permanant redirect, and you have access to the .htaccess file, then a faster, cleaner way of doing this would be to let Apache handle it. If your first script contains nothing but that redirect, then delete it completely and add this line to your .htaccess file:
Redirect 301 /the-first-script.php /mil/index.php