2013-11-04 107 views
0

本地設置工作。而重寫URL好看發現了這個問題 我有部門,類別和產品列表....當我點擊該部門的一個網址是來自問題重寫模塊htacess

Project /index.php?departmentId=1 to 
Project/deptname-d1 

改寫,它會顯示相關的類別,有針鋒相對部門的扭曲是當該類別中選擇一個服務器拋出找不到對象 選定的URL沒有在服務器上發現引用的頁面的鏈接似乎是錯誤或過時的 改寫前的URL將

Project/index.php?departmentId=1&CategoryId=2 

所需的url格式是 項目/ DEPTNAME-D1/catname-C2 在htacess正則表達式是這樣的 選項+的FollowSymLinks RewriteEngine敘述上 RewriteBase /項目 的RewriteCond%{THE_REQUEST}^GET * /指數。(PHP的|?HTML)\ HTTP RewriteRule ^(。 )index。(php | html?)$ $ 1 [R = 301,L] #rewrite部門規則 RewriteRule ^。?-d([0-9] +)/ page - ([0-9] +)/?$ index.php? DepartmentId = $ 1 & Page = $ 2 [L] RewriteRule ^。 ?-d([0-9] +)/?$ index.php?DepartmentId = $ 1 [L] #規則類別 RewriteRule ^。 -d([0-9] +)/ ^。 -c([0-9] +)/ page - ([0-9] +)/?$ index.php?DepartmentId = $ 1 & CategoryId = $ 2 & Page = $ 3 [L] RewriteRule^ -d([0-9] +)/ ^。 c([0-9] +)/?$ index.php?DepartmentId = $ 1 & CategoryId = $ 2 [L] #rewrite產品規則 Rewriterule ^。?-p([0-9] +)/ $的index.php?productId參數= $ 1

改寫以下之前,網址 本地主機/項目/前排 頁本地主機/項目/的index.php? DepartmentId = x部門首頁 localhost/project/index.php?DepartmentId = x & page = zfor department pag localhost/project/index.php?DepartmentId = x & CategoryId = y類別首頁 localhost/project/index.php?DepartmentId = xCategoryId = y & page = z用於分類頁面 localhost/project/ProductId = Q 這些是要以下列格式重寫的輸入Url localhost/project /首頁 localhost/project/department-name-dx /部門首頁 localhost/project/department-name-dx/page-z /部門頁面 localhost/project/department-name- DX /分類名-CY /爲類別前 本地主機/項目/部門名稱-DX /分類名-CY /頁-Z的類別頁面

Please note tat department and product related regex are working fine only the category page is acting weird can someone explain wats going wrong 
+0

修復.htaccess中的規則,並添加:'RewriteRule Project/deptname-d(\ d +)/?$ /index.php?departmentId=$1 [L]' – vmeln

+0

不幸運..我試過你的方法現在服務器拋出錯誤500 – newbie

+0

它不應該,請張貼固定.htaccess – vmeln

回答

0

您正則表達式是錯誤的。您不能將^置於您的正則表達式中。試試這個:

RewriteEngine On 

RewriteRule ^.*?-d([0-9]+)/.*?-c([0-9]+)/page-([0-9]+)/?$ index.php?DepartmentId=$1&CategoryId=$2&Page=$3 [L,QSA] 
RewriteRule ^.*?-d([0-9]+)/.*?c([0-9]+)/?$ index.php?DepartmentId=$1&CategoryId=$2 [L,QSA] 

我建議你在你的問題中提供所有的輸入網址。

+0

沒有工作要麼..ll後張貼輸入Url – newbie

+0

你編輯了你的問題嗎? – anubhava

+0

是啊現在看看它,並對不起,它通過手機上傳 – newbie