Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7968287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:03:10+00:00 2026-06-04T07:03:10+00:00

Right now, I am using a custom PHP solution to force WWW to be

  • 0

Right now, I am using a custom PHP solution to force WWW to be appended to my script URLs, since I am using WordPress’ .htaccess rules to “clean up” index.php. The force WWW .htaccess rules are not compatible with WordPress’ index.php cleanup rules.

With my script, you can browse to “http://scripturl.com/whatever” – my script then has a case for request URI “/whatever” and then does some action (or compiles the respective template) for that view.

I have added a series of checks prior to any any switches being called, which makes sure that the HTTP host from the REQUEST matches the HTTP host from a defined variable in my script. This enforces the addition of the “www”.

My PROBLEM – is that (seemingly when only using IE) – when I enter a url, say “http://myscript.com/whatever”, my script transforms the url to “http://www.myscript.com/whatever”, as expected, and then redirects the header to the new URL. HOWEVER, if I change the URI request from “whatever” to “somethingelse”, the page goes to “http://www.myscript.com/somethingelse” as expected, but for a brief second, “whatever” blinks in the url before the script redirects to “http://www.myscript.com/somethingelse”.

To clarify: start with request “www.myscript.com/sam”. request loads.
Change /sam to /bob -> page changes to “www.myscript.com/bob” but “/sam” flashes in the url bar briefly before /bob loads.

It just doesn’t feel “clean”. I feel like my code might be doing an extra header jump or something. I have contrasted this to wordpress, by going to “www.wordpressurl.com/valid-page”, then changing the URI to “www.wordpressurl.com/another-valid-page” – I don’t see “/valid-page” flash in the URL bar when attempting to access “/another-valid-page”, and vice versa.

Here is my code:

// Requested URL built from url in address bar
$requested_url  = is_ssl() ? 'https://' : 'http://';
$requested_url .= $_SERVER['HTTP_HOST'];
$requested_url .= $_SERVER['REQUEST_URI'];

// Correct url built from predefined variable
$correct_url = is_ssl() ? 'https://' : 'http://';

// "Correct" script url
$user_home = @parse_url('http://www.myscript.com');

if ( !empty($user_home['host']) )
  $correct_url .= $user_home['host'];
else {
  die('malformed url');
}

$correct_url .= $_SERVER['REQUEST_URI'];

// If URL in address bar is not proper, perform redirect (preserve URI)
if ($correct_url != $requested_url) {
  hc_redirect($correct_url, 301);
}

// Get page from request, handle accordingly
$page = $_SERVER['REQUEST_URI'];
switch ($page) {
  /* Index */
  case '/':
    echo "Index queried <br />";

    break;
    ...

Why does the old URI flash in the navbar before the new URI is loaded (from the redirect)? Like I said, this only appears to happen in IE – but WordPress does not have this same behavior (in IE or any other browser), so I know there must be something wrong with my code, an “extra step” which is happening without my knowledge. I’m somewhat new to PHP.

Any thoughts?

Edit: hc_redirect, and other used funcs: http://pastebin.com/fVNEckEg

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:03:11+00:00Added an answer on June 4, 2026 at 7:03 am

    Your script continues to output data after you redirect, the browser waits for the data and only then redirects. If you don’t need to continue execution of the script after you send the redirect header, stop the script’s execution. For example:

    // If URL in address bar is not proper, perform redirect (preserve URI)
    if ($correct_url != $requested_url) {
        hc_redirect($correct_url, 301);
        die();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using JQuery and custom images for custom radio buttons. Right now, it
We are using a Java EE application and we are right now using Informix
Right now I am using std::pair to represent a 2d point in c++. However,
Right now I currently using transactional replication with updatable subscription. Is there any ways
Right now I'm using a few scripts to generate files that I'm including as
Right now I'm using the following: export CFLAGS=-O2-isysroot/Developer/SDKs/MacOSX10.5.sdk -arch i386 -I/sw/include/ export LDFLAGS=-Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk,-L/sw/lib/ sudo
Right now I'm using JFreeChart in order to create a dynamic chart. However the
Right now I'm using: r.forEach( function (el) { el.scale(0.5, 0.5, 0.0, 0.0); }); to
Right now I am using this on my string substr($row->review[$i] , 0, 120) but
Right now I am using the maven-javadoc-plugin to attach the Javadoc to .jar artifacts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.