Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to do this?

Status
Not open for further replies.

mopacfan

Programmer
Oct 30, 2000
190
US
I need to change one of my websites from asp to php. However, so that I don't loose my search engine standings, I need to keep the asp extension, but have it be running php code.

How can I make this happen?

Thanks,
Michael
 
no reason why not. just edit the website properties to run .asp requests through the php isapi handler, or to the php cgi.

the php readme in the installation package will tell you how to do this, just substitute/add .asp for .php.
 
I'd do it using mod_rewrite for apache. Something like
Code:
RewriteEngine On
RewriteBase /
RewriteRule ^(.+).asp$ $1.php [L]

-----------------------------------------
I cannot be bought. Find leasing information at
 
@jaxtell: why would you use mod_rewrite? surely adding a handler is less intensive as the rewrite engine would not need to be loaded?

and I also (probably incorrectly) assumed that the OP was using IIS?
 
yes - but why would you use them when you can change the handler?
 
I guess I should have mentioned that I'm moving the site to a linux server running php.
 
assuming it's an apache installation then you will need to do something like this in your httpd.conf file

Code:
AddType application/x-httpd-php .php .phtml .asp
 
Using mod_rewrite you could use permanent redirects, so search engines and customers could find the new php files.

-----------------------------------------
I cannot be bought. Find leasing information at
 
Mucho thanks. I will see if I have access to the httpd.conf file. Otherwise, I'll go with the mod_rewrite.

Cheers
 
handlers can also be added in local .htaccess files.
 
Ok, cool. So I ftp'd into the webhost and I found the .htaccess file. I could not find an httpd.conf file. So what should I put in the .htaccess file to make the rewrites happen?
 
difficult to know for sure as (I think) it depends on whether you are running php as a cgi or a sapi.

try this
Code:
AddType application/x-httpd-php .php .phtml .asp

and if it does not work, post back the first page of output from a call to phpinfo().
 
or AddHandler. this is probably more strictly 'correct' but given the nature of what php does, either should work.
 
Hi

Feherke said:
There are rewrite engine-like extensions for IIS too.
jpadie said:
yes - but why would you use them when you can change the handler?
To clarify, I just mentioned it to inform the OP about the possibilities. I do not suggest to use URL rewriting. I had bad experience with mod_rewrite's version compatibility and debugging it is not a trivial task for beginners. So I also suggest to set the handler.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top