小编use*_*163的帖子

仅重定向一个页面页面而不影响路径中具有nam的其他URL

我想重定向页面:

http://www.mysite.com/samplepage/
Run Code Online (Sandbox Code Playgroud)

类似的页面http://www.mysite.com/samplepage/samplepage2/不得重定向.

这是我目前的.htaccess代码:

RedirectMatch 301 ^/samplepage/ /new-samplepageurl
Run Code Online (Sandbox Code Playgroud)

问题:这个也重定向网址: http://www.mysite.com/samplepage/samplepage2/

我可以将重定向限制为仅限于一条确切的路径吗?

.htaccess redirect

1
推荐指数
1
解决办法
3088
查看次数

正则表达式以字符串形式找到Youtube链接

我有一个像这样的字符串:

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard  dummy text ever since the 1500s, https://www.youtube.com/watch?v=7TL02DA5MZM when an unknown printer took a galley of type and scrambled it to make a type
Run Code Online (Sandbox Code Playgroud)

这就是我所拥有的:

preg_match("(?:http://)?(?:www.)?(?:youtube.com|youtu.be)/(?:watch\?)?([^\s]+?)", $content, $m);
    var_dump( $m );
Run Code Online (Sandbox Code Playgroud)

并希望从中提取YouTube链接。视频ID也可以。

谢谢您的帮助!

php regex preg-match

1
推荐指数
1
解决办法
2758
查看次数

在 Safari 中强制下载文件

我正在尝试使文件可在 Safari 中下载。这是我的代码:

<?php
$file = $_GET['file'];
header ("Content-Disposition: attachment");
header ("Content-type: application/octet-stream");
header ("Content-disposition: attachment; filename=".$file.";");
header("Content-Length: ".filesize($file));
readfile($file);
exit;
?>
Run Code Online (Sandbox Code Playgroud)

它在 FF 中工作正常,但在 Safari 中我得到一个 0kb 文件。

我想我发送的标题有问题。可能是什么错误?

php safari file http-headers

0
推荐指数
1
解决办法
9699
查看次数

标签 统计

php ×2

.htaccess ×1

file ×1

http-headers ×1

preg-match ×1

redirect ×1

regex ×1

safari ×1