正确配置.htaccess

时间:2013-12-15 04:00:49

标签: apache .htaccess

在localhost上,我在同一个文件夹中有一个文件filename.html和一个.htaccess。

我需要弄清楚为什么我的.htaccess无效:

redirect 301 /filename.html http://www.google.com

我在linux上,我已经配置了服务器:

sudo nano /etc/apache2/sites-available/default

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">

                AllowOverride All
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

sudo service apache2 restart

1 个答案:

答案 0 :(得分:0)

我找到了:

RewriteEngine On
Options +FollowSymLinks
RewriteRule ^test\.html http://www.google.com/? [R=301,L]

我的RewriteEngine正在运作。