URL重写很有难度的?求助!!!!

netehoney 2010-01-23 07:28:04
要求:
重写所有QUERY_STRING中包括有more=XX的url请求,即使真实url存在!!

比如存在test.html文件
http://abc.com/test.html?more=1&other=0
http://abc.com/test.html?other=0&more=1
重写为:
http://abc.com/test.php?other=0&more=1

像http://abc.com/test.html?other=0&u=456这样的就不重写

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING}% ^more=(*)$
RewiteRule ^?(.*)$ /test.php?more=$1 [L]

</IfModule>
我上面的错在哪呢?

错误提示:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
...全文
348 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
netehoney 2010-03-18
  • 打赏
  • 举报
回复
[Quote=引用 19 楼 weijiepeng 的回复:]
引用 3 楼 netehoney 的回复:

顶起,求助呀?
重写实现了,但即便存在真实的URL也重写怎么做呢?

但即便存在真实的URL也重写怎么做呢?
什么意思?
[/Quote]
比如:
访问1 http://abc.com/test/123.html
在abc.com的web服务的test目录下有123.html这个文件,即我说的存在真实的URL。

访问2 http://abc.com/test/123.html?more=1
即便存在123.html时,query_string为more=1就重写到http://abc.com/test/123.php

现在我的问题是,若不存在123.html“访问2”的重写可以实现,但若存在123.html则无法实现重写,访问的还是123.html,这是为什么呢?是不是重写有什么优先级呢?
netehoney 2010-03-18
  • 打赏
  • 举报
回复
拖到最后还是要结贴,今天就结了吧!
weijiepeng 2010-03-17
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 netehoney 的回复:]

顶起,求助呀?
重写实现了,但即便存在真实的URL也重写怎么做呢?
[/Quote]
但即便存在真实的URL也重写怎么做呢?
什么意思?
netehoney 2010-03-17
  • 打赏
  • 举报
回复
#17楼,感谢你一直在帮我,但我这边这个问题确实还在??我也就郁闷了!!
jlzan1314 2010-03-03
  • 打赏
  • 举报
回复
我和你说的.你没用啊.我都测试过了.还有问题啊..
guliputaoyou 2010-03-03
  • 打赏
  • 举报
回复
天天回帖 拿点小分~~~~
小雨转晴 2010-03-02
  • 打赏
  • 举报
回复
友情帮顶!!!!!! 大家跟上吧
BILLSSJONE 2010-03-02
  • 打赏
  • 举报
回复
只有这个顺序重写,其它不重写:
RewriteRule test.html\?(more)=(*)&(other)=(*)$ test.php?$3=$4&$1=$2

netehoney 2010-03-02
  • 打赏
  • 举报
回复
再顶一次,实在解决不了就放了。
netehoney 2010-02-04
  • 打赏
  • 举报
回复
有的是虚拟机,,——错了一个字,
我的是虚拟机
netehoney 2010-02-04
  • 打赏
  • 举报
回复
有的是虚拟机,自己只有修改.htaccess的权限!!!
jlzan1314 2010-02-01
  • 打赏
  • 举报
回复
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} (.*more.*)
RewriteRule test\.html$ /test.php?%1 [L]

</IfModule>
这个重写规则是test.html结尾的 重定向/test.php?... 但是前提是query_string要含more这个字.你试试吧.
fxs_2008 2010-02-01
  • 打赏
  • 举报
回复
重写实现了,但即便存在真实的URL也重写怎么做呢?

当然是重写优先了,因为它是服务器级的

另外,注意不要死循环
netehoney 2010-02-01
  • 打赏
  • 举报
回复
重写实现了,但即便存在真实的URL也重写怎么做呢?
这是不是跟服务器的全局配置有关呢!!!
ruanchao 2010-01-28
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 yw1386 的回复:]
建议你去http://www.seowhy.com 上看一看,还有正则表达式要稍微了解,
推荐一本书《搜索引擎优化高级编程(PHP版)》
[/Quote]
seowhy和这本书,我之前都有看过,是不错的
z445619791 2010-01-28
  • 打赏
  • 举报
回复
up
土地公公 2010-01-27
  • 打赏
  • 举报
回复
帮顶。
yw1386 2010-01-27
  • 打赏
  • 举报
回复
建议你去http://www.seowhy.com 上看一看,还有正则表达式要稍微了解,
推荐一本书《搜索引擎优化高级编程(PHP版)》
netehoney 2010-01-27
  • 打赏
  • 举报
回复
顶起,求助呀?
重写实现了,但即便存在真实的URL也重写怎么做呢?
netehoney 2010-01-24
  • 打赏
  • 举报
回复
抱歉还是一样,你可以在你的服务器上帮我测试一下吗?是不是我的空间有限制呢?
加载更多回复(1)

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧