2010-06-21 135 views
1

RewriteEngine敘述上URL重寫問題

重寫規則bharani $的index.php

在我的.htaccess文件

以上小片段拋出500內部服務器錯誤,

+0

可能屬於對serverfault。 COM。 – cHao 2010-06-21 07:51:10

回答

2
RewriteRule ^index/result_id/([0-9]+)/?$ index.php?result_id=$1 


RewriteRule ^index/article/([0-9]+)/?$ articles.php?article_id=$1 

RewriteRule ^index/product/([0-9]+)/?$ products.php?productid=$1 

將是最好的做

+0

因爲Ids不應該以零開始,所以我寧願做一些類似'^ index/result_id /([1-9] [0-9] *)/?$ index.php?result_id = $ 1'的東西。在你的正則表達式中也有太多關閉的假設。 – 2010-06-21 08:50:14

+0

所以有。是一個錯字。我已經[0-9] +來簡化更長的數字。謝謝。 – 2010-06-21 08:51:47

1

你可能不是在你的正則表達式使用空格。嘗試減少「bharani」和「$」之間的空間。

+0

RewriteEngine敘述上 重寫規則「bharani」和「的index.php」 沒有運氣上述變化也... – Bharanikumar 2010-06-21 07:48:34

1

嘗試

RewriteRule ^/bharani/?$ index.php 

的/?意味着/是可選的。只是櫃麪人們不把它放在

+0

我現在的URL財產以後像 https://www.atnworld.net/fb/index.php?result_id= 1996 我想改變這個到 https://www.atnworld.net/fb/index/result_id/1996 – Bharanikumar 2010-06-21 08:11:21

+0

我已經添加了另一個答案,所以它會更容易閱讀。 – 2010-06-21 08:19:19

0

事情是這樣的:

RewriteRule ^index/([a-zA-Z_-]+)/([0-9]+))/?$ index.php?result_id=$2 

RewriteRule ^index/result_id/([0-9]+))/?$ index.php?result_id=$1 
+0

重寫規則^([0-9] +)$的index.php?result_id = $ 1 該片段固定我概率,但一個doublt是我的網址是像 atnworld.net/fb/index/product/result_id/1996 atnworld.net/fb/index/article/result_id/1996 atnworld.net/fb/index/books/result_id/1996 如何讓這三個DIFF網址,在重寫 – Bharanikumar 2010-06-21 08:23:13

+0

技術上我們已經幫助您的問題。所以你應該發佈這些作爲其他問題。好像我們正在爲你做所有的工作。 – 2010-06-21 08:27:34

+0

缺少.htaccess – Bharanikumar 2010-06-21 08:29:39