문제

I'm trying to force WWW. in Apache's httpd.conf file, not .htaccess, to increase performance. However, when I paste these lines into the first line of httpd.conf, and restart the server, Apache says, "The requested operation failed!".

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Why is this happening, and how can I fix this?

도움이 되었습니까?

해결책

Seems like you're trying to start rewriting without loading the modules. This sort of thing is generally better to configure in a VirtualHost at any rate, as you're mapping a rewrite for a certain site. The error you get basically just means you have a syntax error.

<VirtualHost *:80>
 <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  </IfModule>    
</VirtualHost>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top