Link to home
Start Free TrialLog in
Avatar of PeterDelphin
PeterDelphin

asked on

Best practice for web redirect when redirect page is called from my end-users program?

I have some buttons in my program where each button-click opens a different specific page on my website in the end-user's browser. After some time, I could need to change these target pages, so when the user clicks the button it will open another page instead of the previous one. Of course I will not ask my end-users to download a new version of my program with changed link targets in the program code. So of course I would use REDIRECT pages as target pages for my buttons in the program, so I can edit these pages easily myself without bothering my end-users. These redirect pages will never be viewed directly from the web, only from the buttons in my program. So, for this purpose, which redirect type should I use? HTML or PHP? Certainly not JavaScript, because JavaScript could be deactivated in the user's browser. Should I put a robots.txt in the directory with the redirect pages? Or a specific .htaccess file?

Which is the best practice for this purpose?
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

I think your best bet is to keep 1 button per page.  

On each page you can include files (other php pages) as modules to your program.  If one module needs to be switched out, then just change the included file from page1.php to page1b.php.  You might end up with multiple include files on one page.  

Interested to hear other thoughts.

I don't think it is a good idea to keep redirecting from page A to page B to page C etc.
Avatar of PeterDelphin
PeterDelphin

ASKER

I think you completely misunderstood the question. Please read it again carefully.

Anyway, now I use a PHP redirect which works very well:

<?php
header("Location: http://www.example.com/apage.html");
die();

Open in new window


Any idea about an additional robots.txt in the directory with the redirect pages? Or a specific .htaccess file?
This sounds like an "edge-case" in web application design.  Can you give us some more details?  What does the application do?  Why do you want the same button (link) to produce a different client experience sometimes?  Most UX designers would suggest that predictable and stable navigation is one of the underpinnings of good design.
Robots.txt is used to talk to "good" web crawlers.  It doesn't really come into play in any direct way here because its use is not enforceable.  .htaccess can be used for access control, to rewrite URLs, etc.  But again, unless there is some other strategy at work, I don't see how it would be a part of the design.  Nothing in the design would prevent using either robots.txt or .htaccess, and nothing in the design would need them, too.

What can you tell us about your program? Is it an iOS or Android application?
Sorry for posting a question which (as I see now) could be easily misunderstood. (English is not my native language). I will try to clarify:

This is a Windows program which in addition to its own functionality user interface also has a "Help" button and a "Buy" button (to keep it simple). Now, when the user clicks on the "Help" button, it will open the http://www.example.com/help.html page in his browser. And when he clicks on the "Buy" button, it will open the http://www.example.com/buy.html page in his browser.

Later I could decide that by clicking on the "Help" button the page displayed in the user's browser should be help2.html instead of help.html. (Please don't ask me for the reason, it has a good reason).

So instead of opening the help.html page directly, I make the button open http://www.example.com/redirect.php which redirects to http://www.example.com/help.html page. This allows me to change the page which is opened in the user's browser when he clicks on the button by simply editing the redirect.php page. (Again, there is a good reason for this).

The question about .htaccess and robots.txt has NOTHING to do with the redirecting! I just was concerned about SEO effects or about Google indexing the redirect pages in a wrong way or other similar side effects.
You English is fine - we just need to clarify some things once in a while.

If the Windows program can act like a well-behaved web browser, setting and retrieving cookies, you can use the cookie as a signal to the server.  Based on the cookie, the server can redirect.

You can make the server redirect in other ways, too.  For example, your server is date and location aware.  Your PHP scripts can identify this kind of information and use the header() function to redirect.  Here is an example based on even/odd days.

<?php // demo/temp_redirect.php
error_reporting(E_ALL);

// SEE http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28459865.html

$signal = date('d') % 2;
if ($signal)
{
    header("Location: https://google.com");
    exit;
}
else
{
    header("Location: https://yahoo.com");
    exit;
}

Open in new window

Thank you Ray, this is a very good example for DYNAMIC redirecting.

I need to add some more information:

The web page is opened in the user's web browser (via ShellExecute Windows API), not inside the application. So the question here is: Could there be a situation where the above redirection method (Location...) would possibly not work in the standard web browsers? And more specifically: Is this redirect method the best practice among all alternatives? Sorry for being so specific, but it could mean a loss of revenue if it does not work in some cases.
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial