你好,我有一個應用程式應該用 3 個引數來過濾 url - 模塊 / 視圖 / Id - 但是,必須添加基本的 html 標簽來整理 css/jss url 檔案,但現在我遇到了一個問題,其中 css由于 htaccess 重定向,/jss 檔案未加載。
訪問:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Module
RewriteRule ^([^/] )/?$ index.php?module=$1 [NC,L]
# Module/View
RewriteRule ^([^/] )/([^/] )/?$ index.php?module=$1&view=$2 [NC,L]
# Module/View/Id
RewriteRule ^([^/] )/([^/] )/([^/] )/?$ index.php?module=$1&view=$2&id=$3 [NC,L]
Options Indexes
Options FollowSymlinks
頭檔案:
<base href="http://localhost/mycbsv2/">
<!--begin::Fonts-->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700" />
<!--end::Fonts-->
<!--begin::Global Stylesheets Bundle(used by all pages)-->
<link href="assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css" />
<link href="assets/css/style.bundle.css" rel="stylesheet" type="text/css" />
<!--end::Global Stylesheets Bundle-->
問題是,如果您轉到 css 檔案 url,它不會加載它,因為它將檔案作為模塊搜索(因為 url)...

有沒有辦法在搜索檔案時添加一個例外來不過濾url?
這個問題也可能出現,因為應用程式的所有視圖都是從 index.php 檔案管理的。
uj5u.com熱心網友回復:
重寫條件僅適用于下一個規則。您有一個重寫條件,從重寫中排除實際檔案,但您只對三個規則中的第一個例外。您只需要為每個規則重復條件:
RewriteEngine On
# Module
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/] )/?$ index.php?module=$1 [NC,L]
# Module/View
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/] )/([^/] )/?$ index.php?module=$1&view=$2 [NC,L]
# Module/View/Id
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/] )/([^/] )/([^/] )/?$ index.php?module=$1&view=$2&id=$3 [NC,L]
Options Indexes
Options FollowSymlinks
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/349359.html
