Web server not reading .htaccess file

2019-07-07 00:52发布

I have Ubuntu 12.10 with apache2 installed, and my .htaccess file is not working. I have it set up to be able to not have .php file extensions in the links, so it looks like www.website.com/login instead of /login.php, but it says that the URL "/login" is not found on the server. I have read this page and it says something about "AllowOverride All" but I don't know where that is, or if I need to add it, where I would add it.

EDIT: I have found this link and have found what it says, but it says that I have an Internal Server Error on any page I go to. I have changed the to

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

but it says Internal Server Error

EDIT #2: In the error log, it says

/var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

EDIT #3: Found the answer here: .htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

2条回答
我只想做你的唯一
2楼-- · 2019-07-07 01:27
  • Make sure you have enabled mod_rewrite in your .htaccess.

Also make sure you these lines at the top of your .htaccess:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

i.e. turn the MultiViews options off.

Also see this Q&A for a similar problem and my answer.

查看更多
唯我独甜
3楼-- · 2019-07-07 01:44

You should have or specify Directory-block in your apache configurations. You can find AllowOverride documentation here: http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride

And documentation about <Directory> is here: http://httpd.apache.org/docs/2.2/mod/core.html#directory

In short: specify where you would like to allow the settings to be overridden with <Directory /path/to/your/directory> and then use AllowOverride all in that directory block.

查看更多
登录 后发表回答