Mobile app version of vmapp.org
Login or Join
Bryan171

: Using .htaccess to redirect .asp to .php? Ahoy all! I've been racking my brain with this one. I basically just converted all of my pages from ASP code to PHP code. Kept the same filenames.

@Bryan171

Posted in: #301Redirect #Apache #AspNet #Htaccess #Php

Ahoy all! I've been racking my brain with this one.

I basically just converted all of my pages from ASP code to PHP code. Kept the same filenames.

So, here is the htaccess code I have so far, but it keeps redirecting to my ROOT.... ie /home/accountname/publc_html...

What am I doing wrong?

RewriteRule (.*).asp .php [R=301]

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Bryan171

3 Comments

Sorted by latest first Latest Oldest Best

 

@Angela700

try adding a slash before the target url () like:

RewriteEngine on
RewriteRule ^(.*).asp$ /.php [R=301,NC]

10% popularity Vote Up Vote Down


 

@Moriarity557

If you are running PHP on IIS and know that you don't have any .asp pages left over you can add a handler for IIS to interpret .asp pages as PHP. This is just a neat trick that masks the fact that you are actually running PHP.
@anagio 's rewrite rule will work. Make sure its a permanent redirect by adding the appropriate header.

10% popularity Vote Up Vote Down


 

@Annie201

Try

RewriteEngine on
RewriteRule ^(.*).php$ .asp [nc]

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme