Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there an alternative to .htaccess, in case the webhoster disabled the use of .htaccess files?

I can set some PHP variables and headers inside the PHP files but how can I perform actions like mod_rewrite rules and default 404 pages?

share|improve this question
up vote 8 down vote accepted

...in case the webhoster disabled the use of .htaccess files?

If the webhost has disabled the use of .htaccess files then there is no direct alternative. (.htaccess = per-directory Apache config file)

.htaccess files are not necessary if you have access to the Apache server config. In fact, it is preferable to use the server config instead of .htaccess anyway, but by the sounds of it, you do not have that luxury.

I can set some PHP variables and headers inside the PHP files

With PHP 5.3+ under CGI/FastCGI then you can use .user.ini files for per-directory PHP config settings. But that's just for PHP config settings, eg. error_reporting, include_path, etc. (Mind you, under CGI/FastCGI you need to use .user.ini, since you'll get a 500 internal server error if you try to use php_flag and php_value directives in .htaccess - these are for when PHP is installed as an Apache module.)

If your (shared) host has disabled .htaccess and you are wanting to do more that serve simple files then... find a new host.

share|improve this answer

As far as I know, there are no alternatives.

Seems this topic was discussed from another angle : Alternative to .htaccess (due to bad performance?)

share|improve this answer

It's been a long time since I've used Apache and I don't use PHP but ...

You can set your own HTTP headers, redirect, and just about everything else within a programming environment that doesn't block you from accessing those files. I don't recall where in the flow .htaccess is looked at when PHP pages are executed but you would need to find out, by googling or experimenting, if you can circumvent those rules.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.