[英].HTACCESS - Get the parameter and rewrite
I have a url 我有一个网址
website.com/v2/main-service.php?service=foo-bar
and I want to mask it so that the url will become 我想屏蔽它,以便URL将成为
website.com/v2/foo-bar.html
I have this .htaccess
code 我有这个
.htaccess
代码
RewriteEngine on
RewriteRule ^foo-bar.html$ main-service.php?service=foo-bar
but it's not working. 但它不起作用。 I will appreciate the help.
我将感谢您的帮助。 Thank you.
谢谢。
your rule is correct if you remove the "^" before foo-bar.html, You can add variable and it give something like this : 如果您删除foo-bar.html之前的“ ^”,则您的规则是正确的,您可以添加变量,并给出如下所示的内容:
For this url : http://website.com/v2/foo-bar.html 对于此网址: http : //website.com/v2/foo-bar.html
The rule : 规则 :
RewriteRule (v[0-9])+/([a-z0-9-]+).html$ /$1/main-service.php?service=$2
result for php : http://website.com/v2/main-service.php?service=foo-bar php的结果: http ://website.com/v2/main-service.php?service = foo- bar
Try this here : 在这里尝试:
http://htaccess.mwl.be?share=341609bf-eda9-5a5e-92f5-a2cc3f01f921 http://htaccess.mwl.be?share=341609bf-eda9-5a5e-92f5-a2cc3f01f921
EDIT : I change rule without index.php 编辑:我更改没有index.php的规则
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.