2013-05-03 213 views
0

我正在使用Opencart的SEO Friendly URL已打開。RewriteCond - 我做錯了什麼?

這就是所做的.htaccess文件看起來像這樣

RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L] 
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css) 
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA] 

但我需要在一個文件夾不同的是沒有得到改寫,特別是/電子郵件使用者

尋找各地的網絡,在回答加我做了以下事情:

RewriteCond %{REQUEST_URI} !^/(emailer|js|css)/ [NC] 
RewriteRule^- [L] 
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L] 
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css) 
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA] 

這使得/電子郵件/工作,但其他重寫不。有誰知道我在這裏做錯了嗎?

回答

0

你只要在主要的RewriteRule之前插入它。

RewriteBase/

RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L] 
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_URI} !^\/(emailer|js|css) [NC] 
RewriteCond %{REQUEST_URI} !\.(ico|gif|jpg|jpeg|png|js|css)$ [NC] 
RewriteRule ^([^?]*) index.php?_route_=$1&request_uri=%{REQUEST_URI} [L,QSA] 

注:它沒有測試,但是這應該給你的想法如何做到這一點。

後來編輯:

我已經測試我的代碼,並沒有奏效。我已經編輯它,它現在的工作,是這樣的:

  1. RewriteCond %{REQUEST_FILENAME} !-f =>如果請求是不是一個真正的文件名
  2. RewriteCond %{REQUEST_FILENAME} !-d =>如果請求是不是一個真正的目錄
  3. RewriteCond %{REQUEST_URI} !^\/(emailer|js|css) [NC] =>如果如果請求沒有以以下ico/gif/jpg/jpeg/png/js/js文件的擴展名結尾,那麼根目錄中沒有以emailer/js/css開頭的目錄/文件
  4. RewriteCond %{REQUEST_URI} !\.(ico|gif|jpg|jpeg|png|js|css)$ [NC] = css

注:

  • 測試如果你需要在你的重寫規則斜線與否,追加查詢變量就像我在我的修改例子一樣的,而PHP後打印(在第一行打開標籤)在你的index.php文件中是這樣的:

    print_r($ _ GET ['request_uri']); 退出;

完成測試後,從htacces和index.php中刪除request_uri。

  • 總是用反斜槓逃逸的斜槓,這樣\/
+0

這沒有遺憾的工作。它仍然是重寫/電子郵件。我試着把它放在ico/gif之前和之後等,然後我試着取消它到RewriteCond%{REQUEST_URI}!^/emailer/[NC]。仍然沒有運氣。 – jimbeeer 2013-05-03 09:03:35

+0

我在嘗試很多不同的組合。它會崩潰或重寫網站。這是我到目前爲止: RewriteBase/ RewriteRule^sitemap。xml $ index.php?route = feed/google_sitemap [L] RewriteRule^googlebase.xml $ index.php?route = feed/google_base [L] RewriteCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}! - RewriteCond%{REQUEST_URI}!\。(ico | gif | jpg | jpeg | png | js | css)$ [N] RewriteCond%{REQUEST_URI}!^/emailer /?$ RewriteRule ^([^?] *)index.php?_route _ = $ 1 [L,QSA] – jimbeeer 2013-05-03 09:40:15