WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-17-2008, 06:07 AM
pankaj.sharma pankaj.sharma is offline
WebProWorld New Member
 

Join Date: Feb 2007
Location: Pune
Posts: 14
pankaj.sharma RepRank 0
Default Problem in redirecting URL

I want to redirect http://www.mojopages.com/biz//san-di...92101/18490213 to
http://www.mojopages.com/biz/san-die...92101/18490213

can anyone suggest how can i do this.
Reply With Quote
  #2 (permalink)  
Old 03-17-2008, 06:15 AM
chandrika's Avatar
chandrika chandrika is offline
WebProWorld Veteran
 

Join Date: Oct 2005
Location: Cambridge, UK
Posts: 374
chandrika RepRank 1
Default Re: Problem in redirecting URL

If its permanently moved, on the old page just put this code

Code:
<?
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://www.urlofnewpage.com" );
?>
That is how I have done it on my site, so will be interested to hear if there is any problem with that.
__________________
Hairstyles - Pictures of 2008 hairstyles and a virtual hairstyler demo.
Price Comparison Site - Compare prices of well known brands and products.
Reply With Quote
  #3 (permalink)  
Old 03-17-2008, 03:41 PM
mikesmith76 mikesmith76 is offline
WebProWorld Pro
 

Join Date: Sep 2005
Location: Manchester, UK
Posts: 253
mikesmith76 RepRank 0
Default Re: Problem in redirecting URL

chandrik's method works fine. Only suggestion i would make though is if possible put all your redirects in an .htaccess file. Much neater, saves having a load of php files whose sole purpose is to redirect an url.
Reply With Quote
  #4 (permalink)  
Old 03-18-2008, 10:17 AM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,648
wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: Problem in redirecting URL

If you do not have the ability to set redirects with .htaccess, and your site uses PHP, Chandrika's method would be adequate, although I would suggest two changes to the code:
PHP Code:
<?php
header
('Location: http://www.newurl.com',301);
exit();
?>
This should use lower overhead, and be more resistant to errors. By default, using header('Location') uses a 302 redirect, and some versions of PHP do not use the previously specified HTTP line correctly, so specifying the redirect code in the location line avoids this possible bug. Using the exit() function saves some processing by preventing any further code in the script from being processed, since it will not be visible to the user anyway.

If you have access to htaccess, I would strongly recommend using an explicit redirection:

Code:
# Change oldurl.com/oldpage.html to oldurl.com/newpage.html
Redirect 301 /oldpage.html http://oldurl.com/newpage.html
# Change oldurl.com/oldfolder/page.html to oldurl.com/newfolder/page.html
RedirectMatch 301 ^/oldfolder/(.*)$ http://oldurl.com/newfolder/$1
This method requires the least processing, and will work with any type of file, including images.
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #5 (permalink)  
Old 03-22-2008, 02:20 AM
califmerchant califmerchant is offline
WebProWorld Member
 

Join Date: Mar 2008
Posts: 42
califmerchant RepRank 0
Default Re: Problem in redirecting URL

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


this works too
Reply With Quote
  #6 (permalink)  
Old 03-24-2008, 09:56 AM
wige's Avatar
wige wige is offline
Moderator
WebProWorld Moderator
 

Join Date: Jun 2006
Location: United States
Posts: 1,648
wige RepRank 4wige RepRank 4wige RepRank 4
Default Re: Problem in redirecting URL

Quote:
Originally Posted by califmerchant View Post
<script type="text/javascript">
window.location = "URL"
</script>


this works too
This would work, however search engines are likely to see this as potentially spammy, and would not follow the redirect. In addition, certain Internet security applications may prevent the redirection or, worse, display a security alert to the user.
__________________
The best way to learn anything, is to question everything.
Interestingly Average Security Blog
Reply With Quote
  #7 (permalink)  
Old 03-24-2008, 11:32 AM
activeco activeco is offline
WebProWorld Veteran
 

Join Date: Jul 2004
Posts: 860
activeco RepRank 1
Default Re: Problem in redirecting URL

Pankaj.sharma, do you refer to double slash?
__________________
Vote Hussein, vote humanity
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: 301, redirect, url



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
301 redirect not redirecting thebloke Search Engine Optimization Forum 16 11-29-2006 07:36 AM
Redirecting URL tushar123 Search Engine Optimization Forum 0 11-09-2006 03:12 AM
Problem in redirecting dynamic page to static one ! Pls HELP ashishdabas Search Engine Optimization Forum 2 09-11-2006 04:37 PM
MSN.com redirecting to MSN.co.uk dburdon MSN Search Discussion Forum 4 05-04-2006 09:00 AM
Redirecting without effecting PR icb01co2 Google Discussion Forum 4 06-11-2004 07:10 AM


Search Engine Friendly URLs by vBSEO 3.0.0