Hi
I have a site in Joomla CMS.

I want to redirect my old url :

http://www.brcreation.com/index.php?/Softwares/Tool-to-Convert-Files?itemid=167&mid=167

to :

http://www.brcreation.com/Softwares/Tool-to-Convert-Files?itemid=167&mid=167

As you see above, I want to remove "index.php?/" from my site url.

I have created a script for this but there are some problems. It doesn't redirect to correct url.

Here is my script :

<script type="text/javascript">
var myRegExp = "/index.php\?\//"; // This may be wrong. I dont know more about regexp.
var string1 = window.location;
toString(string1);
//alert( string1 );
var matchPos1 = string1.search(myRegExp);
if(matchPos1 != -1) {
  window.location = string1;
}
</script>

Plese help me on this

Reg pattern(s) in literal forms should not be quoted:

// Instead of -->
myRegExp = "/index.php\?\//";
// Simply change this to -->
myRegExp = /index\.php\?\//;

Or you can try this code:

<html>
<head>
<title>Redirect Demo</title>
<script type="text/javascript">
<!--
var pattern = /index\.php\?\//;
var loc;

// Just be sure that you will put this script in your -

// old page. Or this script will continue to execute if the same location is targeted.

myLocation = function() {
   if ( pattern.test( window.location || document.URL )) {
      try {
loc = document.URL.match( pattern );
      window.location = loc;
      } catch( e ) {
loc = window.location.match( pattern );
      window.location.href = loc;
      }
   } else { alert("\nUnable to redirect the current location!");
   } 
};

if ( window.addEventListener )
window.addEventListener("load",myLocation,false);
else if ( window.attachEvent )
window.attachEvent("onload",myLocation);
else
window.onload = myLocation;

// -->
</script>
</head>
<body>

</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.