I have been searching around the net looking for solutions to my problem, but none have worked. My issue is that when i redirect using:

<meta http-equiv="Refresh" content="0; url=<?php echo $URL; ?>"> 

The hash tag part of URL gets removed by IE. So example.com/sample#foo will just load as example.com/sample. This happens in all version of IE and appears to be a bug, but the question is how do I get around this issue?

Here is the redirect page template for wordpress that I am using:

Template Name: Redirect

<?php if (have_posts()) : the_post(); ?>
<?php $URL = get_the_excerpt(); if (!preg_match('/^http:\/\//', $URL)) $URL = 'http://' . $URL; ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Refresh" content="0; url=<?php echo $URL; ?>"> 


<?php endif; ?>

I understand the hash tag is a client side thing so I have tried the following things with javascript in the head:

<script type="text/javascript">
var theurl = "<?php echo $URL;?>";
  // Redirect to hash if there is no hash in the URL.
  if (window.location.hash == '') {

OR just:

<script type="text/javascript">
  window.location.hash = window.location.hash;

None of these work, so I am thinking I might need to use a cookie method to solve this but I am unsure of how this would be implemented in my particular case.

Thanks in advance!

Edited by TheVendor

5 Years
Discussion Span
Last Post by TheVendor

Messed around with the plugin a bit, but couldn't get anything to work. Any idea of how I would implement this on my redirect php page? So I've called the plugin file and now would I need to put some javascript in the head of the redirect php page?

Edited by TheVendor


I found out that there is actually a really simple solution to my problem. All I needed was a trailing slash before the hash. :/

example.com/sample/#foo instead of example.com/sample#foo

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.