好像忘記啓用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