Brennan
Brennan

Reputation: 1

Redirect file extension (.htaccess)

I was wondering if it were possible to redirect certain ending file types to another extension. It's been done before on a site I visited, but I am unable to find out how.

For exmaple:

If my website had php files and the extension was www.example.com/testfile.php and I want it to show up on the URL as www.example.com/testfile.aspx, how would I do that?

Thanks

Upvotes: 0

Views: 3275

Answers (2)

railsbox
railsbox

Reputation: 888

Use this

<IfModule mod_rewrite.c>

 RewriteEngine On

 RewriteRule ^([^/]*)\.aspx$ $1.php [L]


</IfModule>

Upvotes: 0

Mike
Mike

Reputation: 24363

You could do something like this:

RewriteEngine On
RewriteRule ^(.*)\.aspx$ $1.php [L]

or if you would prefer to actually save the files as aspx on the server instead of redirecting to a PHP script, do something like:

AddHandler application/x-httpd-php .php .aspx

Upvotes: 2

Related Questions