使用 htaccess - 页面未正确加载

working with htaccess - page not being loaded properly

我的 .htaccess 文档中写了以下代码

RewriteEngine On


# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /

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


RewriteRule ^category/([a-z]+)/?$ searchPage.php?crs_category=

RewriteRule ^ index.php [QSA,L]

我认为问题出现在下面一行:

RewriteRule ^category/([a-z]+)/?$ searchPage.php?crs_category=

基本上我想要当用户输入 searchPage.php?crs_category=business 它将 url 重写为 category/businesscategory/business/category/BUSinesS/category/BUsineSS

目前以下问题与此行如下:

  1. css/js 似乎加载
  2. 它仅在我键入 category/business 时有效/如果我键入 searchPage.php?crs_category=business 它不会重定向或重写到干净的 URL

试试这个:

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} /searchPage.php\?crs_category=([^\s]+) [NC] 
RewriteRule ^ category/%1? [NE,NC,R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^category/([^/]+)/?$  searchPage.php?crs_category= [QSA,L,NC]