htaccess的规则不工作在localhost [英] htaccess rule is not working on localhost

查看:218
本文介绍了htaccess的规则不工作在localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起,我改变了previous问题。我有问题,在本地主机上的.htaccess重写规则,我的.htaccess文件中的http://本地主机/测试/的.htaccess。 我想改变URL中包含

Sorry I changed the previous question. I have problem with .htaccess rewrite rule on localhost, I have .htaccess file in http:// localhost/testing/.htaccess. I want to change url like below

http://localhost/testing/site.php?site=test

http://localhost/testing/test

和我有code在.htaccess为

And I have code in .htaccess as

RewriteEngine on
RewriteRule ^([^/\.]+)/?$ site.php?site=$1 [L]

这是工作正确的,但我也URL如

Which is working correct, but I have also url like

http://localhost/testing/pages.php?site=test&pid=2

下面pages.php有两个参数,网站名称和页面ID。我想改写这个为

Here pages.php with two parameters as site name and page id. I want rewrite this as

http://localhost/testing/test/2

对于这两种情况我有波纹管code这是行不通的。

For both conditions I have bellow code which is not working

RewriteEngine on
RewriteRule ^([^/\.]+)/?$ site.php?site=$1 [L]
RewriteRule ^([^/\.]+)/?$ pages.php?site=$1&pid=$2 [L] 

请帮

感谢:)

推荐答案

我该为我工作的解决方案。

I got solution which worked for me.

RewriteEngine on
RewriteRule ^([^/\.]+)/?$ site.php?site=$1 [L]
RewriteRule ^([^/]+)/([^/\.]+)/?$ pages.php?site=$1&pid=$2 [L,QSA]

谢谢大家:)

Thanks everyone :)

这篇关于htaccess的规则不工作在localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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