I have a URL like
我有一个像这样的网址
www.example.com/program.php?course=1&program=Ajay
now with .htaccess I am able to convert it like
现在用.htaccess我可以像转换它一样
www.example.com/program/1/Ajay
but I want to convert it like
但我想把它转换成
www.example.com/program/Ajay
Can any one please suggest how could I do this?
任何人都可以建议我怎么做?
Any help really appreciated.
任何帮助真的很感激。
I used this code
我用过这段代码
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ program\.php\?course=(.*)&program_name=(.*)\ HTTP
RewriteRule ^ /program/%3\? [R,L]
2 个解决方案
#1
0
The following rule should change www.example.com/a.php?x=1&y=2&z=Ajay
to www.example.com/target/Ajay
以下规则应更改www.example.com/a.php?x=1&y=2&z=Ajay更改为www.example.com/target/Ajay
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /program\.php\?course=(.*)&program=(.*)\ HTTP
RewriteRule ^ /program/%3\? [R,L]
RewriteRule ^/program/(.*)$ /program.php?program=$1 [L]
The %4
refers to the value after &z=
. If you wanted the value from ?x=
or &y=
you would use %2
for value in x=
and %3
for value in &y=
%4指的是&z =之后的值。如果你想要来自?x =或&y =的值,你会在x =和%3中使用%2作为&y =中的值
e.g. Change www.example.com/a.php?x=1&y=2&z=Ajay
to www.example.com/target/x/Ajay
例如将www.example.com/a.php?x=1&y=2&z=Ajay更改为www.example.com/target/x/Ajay
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /a\.php\?x=(.*)&y=(.*)&z=(.*)\ HTTP
RewriteRule ^ /target/%2/%4\? [R,L]
#2
0
Here is a simple example, it may help you:
这是一个简单的例子,它可以帮助你:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^post-(.*)-([0-9]+)\.html$ post.php?post_name=$1&post_id=$2 [L]
#1
0
The following rule should change www.example.com/a.php?x=1&y=2&z=Ajay
to www.example.com/target/Ajay
以下规则应更改www.example.com/a.php?x=1&y=2&z=Ajay更改为www.example.com/target/Ajay
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /program\.php\?course=(.*)&program=(.*)\ HTTP
RewriteRule ^ /program/%3\? [R,L]
RewriteRule ^/program/(.*)$ /program.php?program=$1 [L]
The %4
refers to the value after &z=
. If you wanted the value from ?x=
or &y=
you would use %2
for value in x=
and %3
for value in &y=
%4指的是&z =之后的值。如果你想要来自?x =或&y =的值,你会在x =和%3中使用%2作为&y =中的值
e.g. Change www.example.com/a.php?x=1&y=2&z=Ajay
to www.example.com/target/x/Ajay
例如将www.example.com/a.php?x=1&y=2&z=Ajay更改为www.example.com/target/x/Ajay
RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|POST)\ /a\.php\?x=(.*)&y=(.*)&z=(.*)\ HTTP
RewriteRule ^ /target/%2/%4\? [R,L]
#2
0
Here is a simple example, it may help you:
这是一个简单的例子,它可以帮助你:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^post-(.*)-([0-9]+)\.html$ post.php?post_name=$1&post_id=$2 [L]