Question

I want to be able to name my files with whatever extension I choose. In this case let’s use .foo, and then process them as PHP files.

Right now my .htaccess looks like this

AddType application/x-httpd-php .foo

But it doesn’t work, it still prompts me to download the file when I access it.

Any advice or tips?

Was it helpful?

Solution

Try:

rewriteengine on
rewriterule ^(.*)\.foo$ $1.php

OTHER TIPS

AddType application/x-httpd-php .html

The syntax looks right to me .. Did you try rebooting the web server?

Also, are there any other settings in .htaccess file working? I mean just make sure that this file is being parsed.

Try:

AddType application/x-httpd-php .php

And then below it:

AddType application/x-httpd-php .foo

If it does not works try this code:

<FilesMatch "\.(php|foo)$">
    AddDefaultCharset UTF-8
    DefaultLanguage en-US
</FilesMatch>

If you want to you can add the addtype inside the <filesmatch> tag.

You could use mod_rewrite to rewrite the requests of *.foo to *.php:

RewriteEngine on
RewriteRule (.+)\.php$ $1.php

This rule will rewrite any request that’s URL path ends on .foo internally to the equivalent .php URL path.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top