2010-06-21 137 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