Apache DefaultType not working

I would like to do something simple, yet, after many attempts and trying many, many different configurations, I can't get apache to default to php. I would like to do something simple, which is to convert any URL file request that doesn't match to a ".php" default. So, for example,

"http://www.domain.com/index" would become "http://www.domain.com/index.php"

and

"https://www.domain.com/index?user=2" would become "https://www.domain.com/index.php?user=2"

I would simply like to add

"DefaultType application/x-httpd-php"

to the apache configuration to accomplish this.

However, I can't figure it out – i have already tried adding it to

-- httpd.conf

-- the virtual hosts (in sites-available, including to the file named "default")

-- the apache2.conf file

I have tried various combinations of the above.

I am using the recommended install of lamp per the linode guide.

Thanks in advance.

4 Replies

ajw,

I'm assuming that you restarted apache after changing the vhost file and the apache2.conf file.

You can look at this link which offers two options:

http://stackoverflow.com/questions/7516 … web-server">http://stackoverflow.com/questions/7516490/default-to-php-extension-on-web-server

You can make the changes in the link above (probably just one or the other) in your vhost file or an .htaccess file in the site's root directory. Using .htaccess doesn't require a restart to apache, though you'll need AllowOverride All in your vhost file for .htaccess to override setting in your vhost.

MSJ

Thanks - that worked.

I can't figure out why apache is reading my htaccess file since all of the "AllowOverride" I can find are set to " AllowOverride None". This is in /etc/apache2/sites-available/default and /etc/apache2/sites-available/default-ssl. I didn't try to override anywhere else (for example, no entry in the vhost/directory file for the site).

There is probably another file or reference I am missing, but I can't find it (I checked "/etc/apache2/apache2.conf", "/etc/apache2/httpd.conf", "/etc/apache2/conf.d/security").

It works, so I'm going with this solution – but, if you also happen to know where else to verify that the settings are ok (or at least that I know where they are) that would be appreciated.

Thanks.

ajw,

The /etc/apache2/sites-available/default file is for the default site on the VPS. It's not the default settings for your sites. You probably have a file in sites-available with the name of your domain in it (eg, /etc/apache2/sites-available/yourdomainnamehere.com). That is the file that probably has AllowOverride All in it.

MSJ

Thank you. Based on the Apache docs, the default (no pun intended) for Apache AllowOverride is "All", so I'm assuming that is the case here (with no AllowOverride entries in the sites-available file).

Thanks again.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct