好像忘记启用mod_rewrite的(你可以在/var/log/apache2/error.log
检查)或AllowOverride
指令是不存在的。
我做(新鲜的debian /杰西):
# apt-get install apache2
# a2enmod rewrite
add AllowOverride into /etc/apache2/sites-enabled/000-default.conf
# systemctl restart apache2
你的站点的配置应该有AllowOverride All
内<目录>,类似的东西
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
<Directory "/var/www/html">
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
和/ var/www/html等/.htaccess(默认网站)
RewriteEngine on
RewriteCond %{QUERY_STRING} tmpl=component&print=1 [NC]
RewriteRule (.*) /$1? [R=301,L]
这对我有用。
你设置了'RewriteEngine on'吗? – 2016-02-05 11:15:17
@noob我当然没有 –
你使用'apache'吗? – 2016-02-05 11:17:52