Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 如何将具有数值的长URL重写为具有相同值的短URL_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

.htaccess 如何将具有数值的长URL重写为具有相同值的短URL

.htaccess 如何将具有数值的长URL重写为具有相同值的短URL,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,请使用非stardart长URL提供帮助 http://example.com/media/player/player.swf?f=http://example.com/media/player/config.php?vkey=12345 要重写为短URL吗 http://example.com/embed/12345 如果有人请求http://example.com/embed/12345您希望将此内部重写为http://example.com/media/player/player.sw

请使用非stardart长URL提供帮助

http://example.com/media/player/player.swf?f=http://example.com/media/player/config.php?vkey=12345
要重写为短URL吗

http://example.com/embed/12345

如果有人请求
http://example.com/embed/12345
您希望将此内部重写为
http://example.com/media/player/player.swf?f=http://example.com/media/player/config.php?vkey=12345

如果是这样,其工作原理如下:

RewriteEngine On
RewriteRule ^/?embed/([^/]+)$ /media/player/player.swf?f=http://example.com/media/player/config.php?vkey=$1 [L]
如果你真的想用另一种方式来做,那么你必须这样做:

RewriteEngine On
RewriteCond %{QUERY_STRING} ^f=http://example\.com/media/player/config\.php\?vkey=([^&]+)$
RewriteRule ^/?media/player/player\.swf$ /embed/%1 [L]

如果需要重定向,请将
[L]
更改为
[R=301,L]

,而不是相反。我只需要第二个选择(制作简短的URL,如example.com/embed/12345。抱歉,但您的代码不起作用。您需要重定向还是重写?请参阅:stackoverflow.com/a/46595140/5427950我想我需要301重定向,因为在新版本的脚本中,应该是短URL。我不明白为什么此代码不起作用。即使是从旧域ru到网络的301重定向也不起作用。)为这样一个计划的链接工作。所有其他链接都被重定向而没有问题扫描您发布的完整htaccess配置,以及所有其他相关内容