CSS/JSS htaccess 加载问题 URL 重写

CSS/JSS loading problem with htaccess URL rewrite

你好,我有一个应用程序应该用 3 个参数过滤 urls - Module / View / Id - 但是,必须添加基础 html 标签来整理css/jss url 个文件,但现在我遇到一个问题,由于 htaccccess 的重定向,css/jss 个文件未加载。

Htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Module
RewriteRule ^([^/]+)/?$  index.php?module= [NC,L]

# Module/View
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?module=&view= [NC,L]

# Module/View/Id
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?module=&view=&id= [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 文件管理的。

重写条件仅适用于下一个规则。您有一个重写条件,将实际文件排除在重写之外,但您只对三个规则中的第一个进行了例外处理。您只需要重复每个规则的条件:

RewriteEngine On

# Module
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$  index.php?module= [NC,L]

# Module/View
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?module=&view= [NC,L]

# Module/View/Id
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?module=&view=&id= [NC,L]

Options +Indexes
Options +FollowSymlinks