Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
请在url重写方面提供一点帮助!_Url_Mod Rewrite_Url Rewriting - Fatal编程技术网

请在url重写方面提供一点帮助!

请在url重写方面提供一点帮助!,url,mod-rewrite,url-rewriting,Url,Mod Rewrite,Url Rewriting,我有一个关于url重写的简短问题 我有一个网站。比如说http://www.example.com/ 与一些子网站: http://www.example.com/a.php http://www.example.com/b.php 等等 还有一些“特殊”的URL,如 http://www.example.com/c.php?i=1#link1 http://www.example.com/c.php?i=1#link2 http://www.example.com/c.php?i=2#lin

我有一个关于url重写的简短问题

我有一个网站。比如说
http://www.example.com/

与一些子网站:

http://www.example.com/a.php
http://www.example.com/b.php
等等

还有一些“特殊”的URL,如

http://www.example.com/c.php?i=1#link1
http://www.example.com/c.php?i=1#link2
http://www.example.com/c.php?i=2#link1
http://www.example.com/a/
http://www.example.com/c/1/#link1
现在我想编写一个.htaccess文件,将当前URL转换为重写的URL,如

http://www.example.com/c.php?i=1#link1
http://www.example.com/c.php?i=1#link2
http://www.example.com/c.php?i=2#link1
http://www.example.com/a/
http://www.example.com/c/1/#link1
我不是url重写方面的专家,有人能帮我吗

最好的里根

RewriteRule ^a$ a.php [L]

RewriteRule ^c/(.*)/(.*) c.php?i=$1$2

如果静态页面能够正常工作,则不能重写哈希,因为哈希没有发送到服务器(如上所述)。如果需要重写散列,我建议将散列更改为另一个GET变量(例如
u
),在这种情况下,只需将其添加到htaccess:
RewriteRule^c.php?I=(*)&u=(*)c/$1/$2
。如果你只是想离开锚,你可以在重写中省略它,一切都会好起来(…因为服务器从来没有看到哈希/磅符号),在这种情况下,你应该将它添加到你的代码
RewriteRule^c.php?i=(*)c/$1/

可能更一般一些(没有a.php和c.php)?当询问url重写问题时,如果您提供一些输入-输出对,则最有帮助。一个具体的例子,以及通俗的规则,用简单的英语来说,是很好的。重写规则^b.php b/这个规则在做什么?他说他有一些静态页面并引用了
http://www.example.com/a.php
http://www.example.com/b.php
作为示例。我只是想彻底地告诉他,如果他还有一页的话,他怎么能重写。