簡體   English   中英

rewritecond不適用於現有文件

[英]rewritecond not working for existing files

我對mod重寫apache有問題,似乎忽略了重寫條件。

重寫規則在我所有的頁面都在工作時起作用,但是問題出在諸如CSS,IMGS和JS之類的資源上。 在我的html中,我使用"href=assets/css/style.css" ,這是一個現有文件,但是我在index.php上被重定向了...

我做錯了什么嗎?

這是我的虛擬主機配置

 <VirtualHost *:*> ServerAdmin me@local.loc DocumentRoot "c:/wamp/www/Covoiturage" ServerName covoiturage.loc ErrorLog "logs/covoiturage-error.log" CustomLog "logs/covoiturage-access.log" combined <directory c:/wamp/www/covoiturage/> Allow from all AllowOverride all </directory> </VirtualHost> 

這是我的htaccess:

 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ /$1 [R=301,L] RewriteRule ^ index.php [L] 

您正在將RewriteCond添加到錯誤的RewriteRule RewriteCond僅對下一個RewriteRule 試試這個代碼:

RewriteEngine On

## Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [R=302,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM