mod_rewrite的已启用,但不工作 [英] Mod_rewrite is enabled but not working

查看:354
本文介绍了mod_rewrite的已启用,但不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看了一段时间了,我不能得到这个工作。

I have read around for a while and I can't get this to work.

的mod_rewrite已在Apache启用,我已经改变了的AllowOverride所有

mod_rewrite is enabled in Apache and I have changed AllowOverride to all

我的.htaccess看起来是这样的:

My .htaccess looks like this:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ profile.php/?username=$1 [L]

和apache2的我的默认文件看起来像这样:        站长的ServerAdmin @本地

and my default file for apache2 looks like this: 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 None
            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

error.log中

error.log

[Sat May 25 20:13:21 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:13:21 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:13:22 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:13:23 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:14:56 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbf', perhaps misspelled or defined by a module not$
[Sat May 25 20:14:57 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbf', perhaps misspelled or defined by a module not$
[Sat May 25 20:14:59 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbf', perhaps misspelled or defined by a module not$
[Sat May 25 20:14:59 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbf', perhaps misspelled or defined by a module not$
[Sat May 25 20:15:04 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:15:04 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:15:20 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:15:20 2013] [alert] [client (ip)] /var/www/.htaccess: Invalid command '\xef\xbb\xbfRewriteEngine', perhaps misspelled or defined by$
[Sat May 25 20:15:58 2013] [notice] caught SIGTERM, shutting down

在我的网站,我得到一个500内部服务器错误消息。请帮助!

On my website I get a 500 internal server error message. Please help!

推荐答案

试着改变你的code这样:

Try changing your code to this:

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

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ profile.php/?username=$1 [L]

即。转动多视​​图选项关闭。

PS:看你的error.log看起来你以前在你的.htaccess一些特殊字符 RewriteEngine叙述关键字

PS: Looking at your error.log looks like you have some special characters in your .htaccess before RewriteEngine keyword.

这篇关于mod_rewrite的已启用,但不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆