[英].htaccess PHP rewrite link
I have problem and dont have any idea how to solve it. 我有问题,也不知道如何解决。 I have URL like this: http://somedomain.com/link.php?lnk=1&sid=dsds 我有这样的网址: http : //somedomain.com/link.php?lnk=1&sid=dsds
and need to change it to this: 并需要将其更改为:
http://somedomain.com/link/1/dsds http://somedomain.com/link/1/dsds
If there is only one variable I use this: 如果只有一个变量,则使用此变量:
RewriteEngine on RewriteRule ^link/([a-zA-Z0-9_-]+)$ link.php?lnk=$1
But I don't have any idea how to attach that second variable &sid={something} 但我不知道如何附加第二个变量&sid = {something}
Thanks in advance for any help. 在此先感谢您的帮助。
RewriteEngine on
RewriteRule ^link/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ link.php?lnk=$1&sid=$2
if the first parameter/value uses digits only, then you can use 如果第一个参数/值仅使用数字,则可以使用
RewriteEngine On
RewriteRule ^link/([0-9]+)/([a-zA-Z0-9_-]+)$ link.php?lnk=$1&sid=$2 [L]
Apache mod_rewrite Introduction (see "Figure 1" in "Regex Back-Reference Availability" section) Apache mod_rewrite简介 (请参阅“ Regex反向引用可用性”部分中的“图1”)
Try this: 尝试这个:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^lnk=(.+)\&sid=(.+)
RewriteRule ^link\.php link/%1/%2/? [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.