搜索引擎友好的URL(的.htaccess) [英] SEO friendly URLs (.htaccess)

查看:309
本文介绍了搜索引擎友好的URL(的.htaccess)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://www.domain.com/folder/file?x=1&y=2

更改为:

http://www.domain.com/folder/file/1/2/


http://www.domain.com/folder/?x=1

更改为:

http://www.domain.com/folder/1/


我想:


I tried:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder/(.*)/$ folder/index.php?x=$1 [L]
RewriteRule ^folder/file/(.*)/(.*)/$ folder/file.php?x=$1&y=$2 [L]

但是,这并不正常工作,没有任何人有任何想法,为什么?

but that doesn't work, does anyone have any idea why?

当我拿出的第一个规则,我可以通过访问第二个:

when i take out the first rule, i can access the second one via:

http://www.domain.com/folder/1/2/

而不是

http://www.domain.com/folder/file/1/2/

上帝,我希望我没有混淆人谁在读这大声笑我希望这是有道理的。

god, i hope i am not confusing anyone who is reading this lol i hope it makes sense

推荐答案

尝试

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^folder/file/(.*)/(.*)/ /folder/file.php?x=$1&y=$2 [L]
RewriteRule ^folder/(.*)/ /folder/index.php?x=$1 [L]

的规则的顺序是很重要的。你应该始终把具有最规则首先作为自己的方式越来越的第一条规则,然后停止,因为它总是正确的,由于(。*)这是捕捉文件

这篇关于搜索引擎友好的URL(的.htaccess)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆