2015-07-20 54 views
1

我写我的.htaccess文件与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=business 它将url重写为category/businesscategory/business/category/BUSinesS/category/BUsineSS

因为它代表了以下问题此行是如下:

  1. 的CSS/JS似乎加载
  2. 它只有当我键入类/业务/如果我键入searchPage.php工作?crs_category =业务并不重定向或重写,以干净的URL
+0

重写[R ule将无法为你做到这一点。使用JavaScript,看看这里http://stackoverflow.com/questions/3338642/updating-address-bar-with-new-url-without-hash-or-reloading-the-page – Jigar

回答

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] 
+0

谢谢你的答案,和建议,尽管有两件事:在本地主机上重写似乎将其重写为http:// localhost/opt/lampp/htdocs/website/category/Web%2520development默认情况下为localhost/website /,并且我键入localhost/website/searchPage.php?category = business第二个问题是由于某些原因,当url重写完成后,relvant css/js文件未加载 – John

+0

取消注释或添加RewriteBase /行,并解决js和css问题,您可以 更改页面标题中的URI基础(在''标记之间,添加 ''' – starkeen