繁体   English   中英

500内部服务器错误.htaccess

[英]500 Internal server error .htaccess

下面给出的.htaccess代码正在获取内部错误

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^([w]{3,3}[.]{1,1}){0,1}example.com$
RewriteCond %{HTTP_HOST} ^([0-9a-zA-Z-]*)[.]example.com$
RewriteRule ^$ portfolio/index.php?id=%1 [NC,L]

AuthType Basic
AuthName "If your not authenticated , then go seat in corner"
AuthUserFile /var/www/devRoot/.htpasswd
Require valid-user

但是如果我只使用

AuthType Basic
AuthName "If your not authenticated , then go seat in corner"
AuthUserFile /var/www/devRoot/.htpasswd
Require valid-user

上面的代码工作完美。

问题是我无法理解为什么第一个代码不起作用。

日志:

[Wed Jul 10 13:12:11 2013] [alert] [client 1.23.112.242] /var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configur                             ation
[Wed Jul 10 13:12:12 2013] [alert] [client 1.23.112.242] /var/www/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configur                             ation

解决了 :

Did you ensure the RewriteEngine is on?

You'll want to verify that the mod is enabled - just look for rewrite.load symlink in /etc/apache2/mods-enabled. If not, run sudo a2enmod rewrite to enable it. Restart apache using sudo service apache2 restart and provided your .htaccess syntax is correct this will work.

Otherwise you will need to paste more information about your .htaccess file.

您尚未启用重写引擎,请取消注释httpd.conf中的行

LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

您可能在/ etc / apache2 / mods-available中拥有它,在这种情况下,只需将其复制到启用了mods的设备并重新启动

多数民众赞成在假设Linux的?

您寻找的窗户

LoadModule rewrite_module modules/mod_rewrite.so

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM