Forum Moderators: phranque

Message Too Old, No Replies

How to redirect every dynamic .asp page to their .php equivalent?

redirect .asp to .php

         

alpacinofr

11:45 am on Dec 18, 2006 (gmt 0)

10+ Year Member



Hi,

I want to move from Windows to Linux server. Should redirect every old .asp page to new .php page on Linux. I will preserve all URL intact (the same) except extension.

Pages are dynamic ie. page.asp?kat=23&lang=de to page.php?kat=23&lang=de

Anyone knows redirect mod rule for acheive this goal. Many old pages are indexed as .asp pages in Google.

I need to redirect each page click .asp going automatically to .php

I need also 301 redirect (permanent)

Thank you.

webdoctor

11:50 am on Dec 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I will preserve all URL intact (the same) except extension.

Why not preserve all the URLs intact and KEEP the extension?

You can configure apache/php to parse .asp files even though they'll be written in PHP.

Moving every single page on your site, even if only from foo.asp to foo.php, is not a good idea unless it's absolutely necessary, and IMHO in your situation it isn't.

apsivam

12:08 pm on Dec 19, 2006 (gmt 0)

10+ Year Member



you must have something like this in your apache configuration file

AddType application/x-httpd-php .php .phtml .php3

just append .asp to the file extension list like this

AddType application/x-httpd-php .php .phtml .php3 .asp

now all files having extension asp will also be parsed by PHP engine.

coopster

12:10 am on Dec 20, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, alpacinofr and apsivam.

Good advice given here, no need to change the extensions if you don't want to yet. Here is a relative thread in PHP that discusses the same topic, just different extensions.

Do I have to change .html to .php? [webmasterworld.com]

alpacinofr

6:20 am on Dec 20, 2006 (gmt 0)

10+ Year Member



thank you all. good idea to keep all pages in asp. anyway i am using always 2 files .php for programing code and .html for formating purposes. i have been added directive DirectoryIndex index.php for default page

alpacinofr

10:59 pm on Dec 30, 2006 (gmt 0)

10+ Year Member



Just one addition. My provider has installed my server with suphp module. Is there any difference for setting up handling .asp extensions as .php

Section global for suphp look like this (Apache2/php5):

#SuPhp
suPHP_Engine on
AddHandler x-httpd-php5 .php5
AddHandler x-httpd-php4 .php4
suPHP_AddHandler x-httpd-php5
suPHP_AddHandler x-httpd-php4

Do I need add .asp at the end of two lines AddHandler....?

Thanks?

coopster

6:08 pm on Jan 2, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes, more than likely you will.