使用htaccess - 页面未正确加载

时间:2015-07-20 16:40:56

标签: php apache .htaccess url url-rewriting

我在"My dog is %s" % fido.to_s文档

中编写了以下代码
.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=$1

RewriteRule ^ index.php [QSA,L]

基本上我想在用户输入RewriteRule ^category/([a-z]+)/?$ searchPage.php?crs_category=$1 时 它将网址重写为searchPage.php?crs_category=businesscategory/businesscategory/business/category/BUSinesS/

对于以下问题,此行如下所示:

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

1 个答案:

答案 0 :(得分:1)

试试这个:

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=$1 [QSA,L,NC]