mod_rewrite - converting .asp to .php

  • rjstephens
  • Professor
  • Professor
  • User avatar
  • Posts: 774
  • Loc: Brisbane, Australia

Post 3+ Months Ago

I am building a website for a lawyer, and he wants the file extensions to be .asp. He says that ASP is considered more "professional", and that to appear to be using Windows server portrays a good corporate image.

And he told me all this after I had built him a complete website in PHP.

So here is my problem. I want to convert all calls to anything .asp to anything .php. I am using a simple mod_rewrite rule to do it for one file:
Code: [ Select ]
RewriteRule ^index.asp /index.php


but, well, this only does it for one file.

How would I modify this rule so that whatever you type, the .asp will be converted to .php ?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Upfront, I don't have an answer to your question. I'll just waste the space with this comment. Do me a favor and slap your lawyer. He needs to wake up and smell the coffee. I'll support ASP and Windows servers in my own way, but that has got to be one of the most stuck-up unprofessional bits of logic for deciding on how a web site should be coded that I have ever heard.
  • rjstephens
  • Professor
  • Professor
  • User avatar
  • Posts: 774
  • Loc: Brisbane, Australia

Post 3+ Months Ago

i know. I had to argue with him for about 10 minutes to convince him that mod_rewrite and PHP was ok, and that his visitors would have no idea. But as long as he has money I don't care :lol:
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

rjstephens wrote:
He says that ASP is considered more "professional", and that to appear to be using Windows server portrays a good corporate image.


HAHAHAHAHAHA LMAO!!! ROFL!!!! HAHAHAHAAH! :mrgreen:

(please feel free to shot him this post) ;)
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Windows server only shows that the company has a lot of money to waste on a Operating System which should not be used for servers or Desktops at that. I only use it because it has more games for it to keep me occupied and WineX still has some bugs in it. Anyway what you could do is check out this page: http://www.ozzu.com/programming-forum/quick-tip-mod-rewrite-t23460.html and that should do you a big helping.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Only a Lawyer would say somthing like that :lol:
I bet this guy has said somthing along theese lines a few times :wink:
"As long as you don't come to court looking like a drug dealer you'll get off the hook, Trust me"
  • rjstephens
  • Professor
  • Professor
  • User avatar
  • Posts: 774
  • Loc: Brisbane, Australia

Post 3+ Months Ago

here is the rewrite rule I used:
Code: [ Select ]
RewriteRule ^(.*).asp$ /$1.php [L,NC]


scorpius, I wouldn't say windows is that bad, have you seen microsoft's latest benchmarks for ws2003? Apparently the TCO is like 20% lower than linux and it is like 30% faster. I looked at them for a bit and couldn't figure out how they were able to rig it like that. I'll see if I can find the link.

and the lawyers aren't the only ones, here in Australia the government runs windows server on all their sites, even the ones that only host static HTML files.

By the way, WTF is with governments paying upwards of $600,000 to have their websites designed? What type of company charges that much?
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Well, I've used both Windows Server 2003, and many different versions of Linux. Although some Linux OSs are a little harder to setup than Windows Server 2003, they always seem to run smoother, and never run into any problems. But if someone really wants to use it I guess its not that bad if you do not have much experience with installing Linux.
  • rjmthezonenet
  • Expert
  • Expert
  • User avatar
  • Posts: 526
  • Loc: St. John's, Newfoundland, Canada

Post 3+ Months Ago

Lawyers! Sheesh!

mod_rewrite?! Why not:

Code: [ Select ]
LoadModule php4_module modules...
AddType application/x-httpd-php .asp
  1. LoadModule php4_module modules...
  2. AddType application/x-httpd-php .asp

?
  • rjstephens
  • Professor
  • Professor
  • User avatar
  • Posts: 774
  • Loc: Brisbane, Australia

Post 3+ Months Ago

excuse me for my ignorance but I don't do much messing around in my .htaccess . What exactly is that supposed to do?
  • Managedlinks
  • Proficient
  • Proficient
  • Managedlinks
  • Posts: 294

Post 3+ Months Ago

.htaccess is a text file containing server directives

preferably you would make the changes to the default.conf file but because most of us don't have access to that you can use .htaccess

take a look at the following page it outlines what you need to do.
http://www.managedlinks.com/htaccess.html

just change the .html to .asp and you will solve your dillema

eg.
Code: [ Select ]
AddType application/x-httpd-php .php .asp
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

I'd use the other method, but incase you were curious:

Code: [ Select ]
RewriteRule ^(*.).asp$ $1.php


Should do it for you.
  • Managedlinks
  • Proficient
  • Proficient
  • Managedlinks
  • Posts: 294

Post 3+ Months Ago

try
Code: [ Select ]
RewriteEngine on
RewriteRule ^(.*).asp$ $1.php
  1. RewriteEngine on
  2. RewriteRule ^(.*).asp$ $1.php


You need to start the rewrite engine and the asterix was in the wrong place it will generate a server 500 fault as it was
  • rjstephens
  • Professor
  • Professor
  • User avatar
  • Posts: 774
  • Loc: Brisbane, Australia

Post 3+ Months Ago

i don't really like to quote myself, but
rjstephens wrote:
here is the rewrite rule I used:
Code: [ Select ]
RewriteRule ^(.*).asp$ /$1.php [L,NC]



thanks anyway.

Post Information

  • Total Posts in this topic: 14 posts
  • Users browsing this forum: hFJyCxL1 and 130 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.