伙计们。我正在使用代码点火器。我使用 .htaccess 从我的 url 中删除了 'index.php',并在我的 default.conf 中添加了“Allow from all”。'index.php' 已成功删除并且站点正在运行。但自从上次更新 apache 以来,.htacess 停止工作,并且 'index.php' 在 url 中变得必要。这是我新更新的 000-default.conf。
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
#vim: syntax=apache ts=4 sw=4 sts=4 sr noet
我在我的 000-default.conf 中添加了以下几行,但没有用:
AllowOverride all
Order allow,deny
Allow from all
我的 .htaccess 没问题,因为它在上次更新 Apache 之前工作正常。
Options -Indexes
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|assets|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteCond %{REQUEST_URI} ^htaccess/ [NC,OR]
RewriteCond %{REQUEST_URI} ^system/function/ [NC,OR]
#just make sure the last rule does NOT have an OR
RewriteCond %{REQUEST_URI} ^system/class/ [NC]
RewriteRule . - [R=404,L,NC]
我的 apache 版本是 2.4.6。现在请告诉我要添加什么到 000-default.conf 以使 .htaccess 正常工作并从我的站点 url 中删除 'index.php'。
PS:我使用的是 ubuntu 12.04。mod_rewrite 已启用。我已启用 000-default.conf 即它在我的启用站点的文件夹中可用。