2017-03-16 122 views
0

不工作我有一個虛擬主機local.mywebsite.com,我在的httpd的虛擬主機使用重寫規則 在我的.htaccess文件XAMPP的mod_rewrite在本地主機虛擬主機

<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] 

。 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> 

和在httpd.conf

DocumentRoot "C:/xampp/htdocs" 
<Directory "C:/xampp/htdocs"> 
Options Indexes FollowSymLinks Includes ExecCGI 
AllowOverride All 
Require all granted 

和我去掉在LoadModule rewrite_module模塊/ mod_rewrite.so

但local.mywebsite.com/fr返回錯誤404

+0

你有沒有在httpd.conf中註釋'LoadModule rewrite_module modules/mod_rewrite.so'? – jim

+0

我在窗口,所以我通過編輯的httpd文件手動做到了,我去掉在LoadModule rewrite_module模塊/ mod_rewrite.so – Amine

回答

0

取消註釋rewrite_module modules/mod_rewrite.so後,您是否重新啓動了apache? 如果不是這樣,重新啓動apache。如果是,請檢查httpd.conf文件中是否包含httpd-vhosts.conf。如果不是這樣點它。

讓sur在你的項目中有這個文件夾「fr」。

如果仍然沒有工作,我推薦你把這個項目在htdocs文件夾中的文件夾XAMPP。可能存在權限問題。

+0

我並不需要添加FR文件夾,因爲它是一個(虛擬文件夾)中重寫規則,以便我就像你說的那樣是一個正確的訪問問題 – Amine

+0

當然你的權利。讓我知道,如果它的工作 –

+0

不幸的是,把項目在htdocs文件夾它不能正常工作:( – Amine