Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!



Photo
- - - - -

Redirect From .asp To .php


  • Please log in to reply
9 replies to this topic

#1 bims

bims

    HR 4

  • Active Members
  • PipPipPipPip
  • 118 posts
  • Location:London, UK

Posted 12 August 2009 - 09:09 AM

Hello, I've finished migrating my website to a PHP based CMS, and will be changing hosts in the process from an IIS environment to Apache. I'm guessing this shouldn't be too much of a problem and I can put the .htaccess on the root of my Apache Server, which contains all the redirects. In total I'm looking to redirect over 100 pages.

I have no idea how to script the such redirects and I've had a look at some of the codes on this site but I'm a bit lost. Also, very concerned as I want any loss in placement to be temporary.

I would also like to know the deal with redirecting dynamic pages. For example, I have a news app with urls such as www.mywebsite.com/news/news_item.asp?NewsID=169

Can I do this redirect?

Would also it be possible to redirect any news item in the old site to the new default news page in the news site?

I'm looking for some pointers with the coding. Please help, thanks.

#2 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 12 August 2009 - 09:50 AM

First, have the .asp page names and paths stayed the same, with only the extension changing to .php?

If so, you can use a more mass type of redirect that pegs to the extension. If not, you'll need to set up individual page redirects. So it's an important question to answer.

If paths and file names remained consistent so you can do a mass redirect of all .asp pages to their .php equivalent it would look like:

CODE
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/(.*)\.asp
RewriteRule ^(.*)\.asp$ http://www.yoursite.com/$1.php [R=301,L]


That's just one way to do it btw. There are several.

Dunno what you want to do with redirecting the news pages exactly. Were you wanting to simply redirect any traffic to /news/news_item.asp to a main news page? If so, that one will be a piece of cake. It would look something like:

CODE
RewriteRule ^/news/news_item\.asp http://www.yoursite.com/news_landing_page.php? [R=301,L]


Note that question mark (?) at the end of the new php news page. That's there to strip off queries that may have been present from the original request so that they end up at your main new landing page.

#3 bims

bims

    HR 4

  • Active Members
  • PipPipPipPip
  • 118 posts
  • Location:London, UK

Posted 12 August 2009 - 11:00 AM

Thanks Randy.

Regarding the newspages, that is more or less what I want to do, I don't want to try redirecting individual news items. So thanks for that!

The names and paths of the pages change. In the last structure most of the main pages were in the root, www.mywebsite.com/bookhotel.asp

In the new structure, it's been organised to look like www.mywebsite.com/services/bookhotel.html
(they are .html page spawned from an SEF component)



#4 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 12 August 2009 - 12:57 PM

Okay. So if it were me I'd leave the News as a mass redirect as laid out above.

For the rest you'll need to do individual page redirects. Again there are several ways to do it. If it were me I'd use RedirectMatch since that'll be slightly easier on the server's load. You'll need one line for each page you're redirecting, but there will be less overall cpu usage by Utilizing RedirectMatch as opposed to using mod_rewrite. So the single line for your bookhotel example would look something like:

CODE
RedirectMatch 301 ^/bookhotel\.asp http://www.yoursite.com/services/bookhotel.html


(Make sure you escape the dots just before the extension in the first part of the statement with a backslash character.)

#5 bims

bims

    HR 4

  • Active Members
  • PipPipPipPip
  • 118 posts
  • Location:London, UK

Posted 12 August 2009 - 02:59 PM

thanks Randy!! I'm going to give it go. Will probably report back in a week and a half or so.

Much appreciated!

#6 bims

bims

    HR 4

  • Active Members
  • PipPipPipPip
  • 118 posts
  • Location:London, UK

Posted 11 September 2009 - 02:03 PM

Thanks. Does this look ok? I get 500 error everytime i upload it and can't quite figure out why. It's probably something elementary. Is there a limit to the amount of redirects that can be put in the file? Also should it be in any particular positon on the .htaccess file? Top maybe? My .htaccess also has some code relating to SH404 component.. thanks!



#7 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 11 September 2009 - 05:00 PM

Without testing it, my guess is the tilde character (~) is probably being encoded. Two things you might try.

First you could try simply replacing the tilde characters with its encoded equivalent, which I believe is %7E. Or you could try escaping the tilde characters by preceding it with a backslash character. If my guess is correct that the tilde is being encoded before being sent, the first of the above will probably do the trick.

You could also convert all of them from the mod_alias approach of using RedirectMatch to the mod_rewrite approach of using RewriteRule. mod_rewrite would allow you to use a catchall to get around the tilde character and match against everything else.

As an aside, is there a reason you're redirecting some to an IP number instead of a domain name? You do realize this can cause some confusion for the search engines if you're actively telling them to index some or all of the site via the ip address right? I wouldn't do it that way personally. I'd get the files uploaded to a domain name and deliver 'em from there.

#8 bims

bims

    HR 4

  • Active Members
  • PipPipPipPip
  • 118 posts
  • Location:London, UK

Posted 11 September 2009 - 07:09 PM

Thanks.. actually, this is a test script.. i wanted to make sure it actually works before changing nameservers. it's the temporary address for the site.. so the /~visitsie will go as it is the root.. and
CODE
http://65.60.58.194/~visitsie/
will become my domain name. I guess the only way to properly test it is when it goes live.. just don't want to bring the entire site down smile.gif on the day of relaunch. You're very helpful thanks.

I'm guessing the redirect script can be located anywhere in the .htaccess file right? And that's not too many redirects..

#9 bims

bims

    HR 4

  • Active Members
  • PipPipPipPip
  • 118 posts
  • Location:London, UK

Posted 14 September 2009 - 06:14 AM

I'm trying to edit my post to remove the code. Isn't this possible?

Thanks..

#10 Jill

Jill

    Recovering SEO

  • Admin
  • 33,003 posts

Posted 14 September 2009 - 08:46 AM

QUOTE(bims @ Sep 14 2009, 07:14 AM) View Post
I'm trying to edit my post to remove the code. Isn't this possible?


Done.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

SPAM FREE FORUM!
 
If you are just registering to spam,
don't bother. You will be wasting your
time as your spam will never see the
light of day!