[英]xampp mod_rewrite not working in localhost VirtualHost
I have a VirtualHost local.mywebsite.com , I use Rewrite rules in my .htaccess file 我有一个VirtualHost local.mywebsite.com,我在.htaccess文件中使用了重写规则
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
RewriteCond %{QUERY_STRING} (\"|%22).*(<|>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (javascript:).*(\;) [NC,OR]
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3) [NC,OR]
RewriteCond %{QUERY_STRING} (\;|\'|\"|%22).*(union|select|insert|drop|update|md5|benchmark|or|and|if) [NC,OR]
RewriteCond %{QUERY_STRING} (base64_encode|localhost|mosconfig) [NC,OR]
RewriteCond %{QUERY_STRING} (boot\.ini|echo.*kae|etc/passwd) [NC,OR]
RewriteCond %{QUERY_STRING} (GLOBALS|REQUEST)(=|\[|%) [NC]
RewriteRule .* - [E=BadQueryString,F]
RewriteRule ^ - [E=BASE:{DOCBASE}] [L]
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTPS}:s on:(s)
RewriteRule ^(.*)$ http%1://local.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_URI} /admin/
RewriteRule .* - [S=2]
RewriteRule ^(.*)index\.php$ %{ENV:BASE}$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9!-/]*)$ %{ENV:BASE} [L]
in the httpd-vhosts.conf 在httpd-vhosts.conf中
<VirtualHost *:80>
DocumentRoot "E:/websites/local.mywebsite.com"
ServerName local.mywebsite.com
<Directory "E:/websites/local.mywebsite.com">
# AllowOverride All # Deprecated
# Order Allow,Deny # Deprecated
# Allow from all # Deprecated
AllowOverride All
# --New way of doing it
Require all granted
</Directory>
and in httpd.conf 并在httpd.conf中
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
and i uncomment the LoadModule rewrite_module modules/mod_rewrite.so 我取消注释LoadModule rewrite_module modules / mod_rewrite.so
but local.mywebsite.com/fr return Error 404 但是local.mywebsite.com/fr返回错误404
Have you restarted apache after uncommenting rewrite_module modules/mod_rewrite.so ? 取消注释rewrite_module modules / mod_rewrite.so后,是否重新启动了Apache? If not so restart apache. 如果不是这样,请重新启动apache。 If yes check If in your httpd.conf file httpd-vhosts.conf is included. 如果是,请检查您的httpd.conf文件中是否包含httpd-vhosts.conf。 if not so Dot it. 如果不是这样的话。
Make sur there is this folder "fr" in your project. 确保您的项目中存在此文件夹“ fr”。
If it is not still working I recommand you put the project in your htdocs folder in xampp folder. 如果仍无法正常工作,我建议您将项目放在xampp文件夹的htdocs文件夹中。 There may be a right acces problem. 可能存在权限问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.