如何htaccess重定向这个长URL?

时间:2022-07-18 10:42:48

I am trying to get my script working. How to redirect and customize the below URL?

我想让我的脚本工作。如何重定向和自定义以下URL?

https://example.com/order?send=value1&send2=value2&send3=value3

to

https://example.com/order/value1/value2/value3

3 个解决方案

#1


0  

Try this rule:

试试这条规则:

RewriteEngine On

RewriteRule ^(order)/([^/]+)/([^/]+)/([^/]*)/?$ /$1?send=$2&send2=$3&send3=$4 [L,NC,QSA]

#2


1  

this site can help you: http://www.generateit.net/mod-rewrite/

这个网站可以帮助你:http://www.generateit.net/mod-rewrite/

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /order?send=$1&send2=$2&send3=$3 [L]

#3


0  

It is not that easy as you think. You have multiple get request (like it should be dynamical).

这并不像你想象的那么容易。你有多个get请求(就像它应该是动态的)。

Can be done like:

可以这样做:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^/order/([a-zA-Z0-9\/\_\-]+)$ /index.php/order?send=$1 [QSA,L]

And in PHP you have $_GET['send'] = value1/value2/value3

在PHP中你有$ _GET ['send'] = value1 / value2 / value3

So you can $getVars = explode("/", $_GET['send']);

所以你可以$ getVars = explode(“/”,$ _GET ['send']);

This way you can add another value4 for example.

这样您就可以添加另一个值4。

#1


0  

Try this rule:

试试这条规则:

RewriteEngine On

RewriteRule ^(order)/([^/]+)/([^/]+)/([^/]*)/?$ /$1?send=$2&send2=$3&send3=$4 [L,NC,QSA]

#2


1  

this site can help you: http://www.generateit.net/mod-rewrite/

这个网站可以帮助你:http://www.generateit.net/mod-rewrite/

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /order?send=$1&send2=$2&send3=$3 [L]

#3


0  

It is not that easy as you think. You have multiple get request (like it should be dynamical).

这并不像你想象的那么容易。你有多个get请求(就像它应该是动态的)。

Can be done like:

可以这样做:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^/order/([a-zA-Z0-9\/\_\-]+)$ /index.php/order?send=$1 [QSA,L]

And in PHP you have $_GET['send'] = value1/value2/value3

在PHP中你有$ _GET ['send'] = value1 / value2 / value3

So you can $getVars = explode("/", $_GET['send']);

所以你可以$ getVars = explode(“/”,$ _GET ['send']);

This way you can add another value4 for example.

这样您就可以添加另一个值4。