Tag: redirect

302和307redirect有什么区别?

302 FOUND和307 TEMPORARY REDIRECT HTTP响应有什么区别? W3规范似乎表明,它们都用于临时redirect,除非响应明确允许它们都不能被caching。

Python + Django页面redirect

如何在Django中完成一个简单的redirect(例如ColdFusion中的cflocation ,或PHP中的header(location:http://) )?

如何在Ruby On Rails中redirect到上一页?

我有一个页面列出了所有具有可sorting标题和分页的项目。 path: /projects?order=asc&page=3&sort=code 我select编辑其中一个项目 path: projects/436/edit 当我点击该页面上的保存时,它会调用项目控制器/更新方法。 在我更新代码之后,我想要redirect到我之前单击编辑特定项目之前的path。 换句话说,我想在同一个页面上进行相同的sorting。 我看到link_to(:back),并认为:back可能在redirect_to(:back)中工作,但这是不行的。 puts YAML::dump(:back) yields the following: :back 任何想法我怎么能得到这个工作。 这似乎是一个容易解决的问题,但我是RoR的新手。

redirect到JavaScript中的相对URL

我有一个问题:我想通过JavaScriptredirect到上面的目录。 我的代码: location.href = (location.href).substr(0, (location.href).lastIndexOf('folder')); 该url如下所示: domain.com/path/folder/index.php?file=abc&test=123&lol=cool redirect只影响这个: domain.com/path/&test=123&lol=cool 但是想要这样做: domain.com/path/ 我怎么能这样做?

有没有办法使用命令行cURL跟踪redirect

我知道在一个PHP脚本中: curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 将遵循redirect。 有没有办法使用命令行cURL遵循redirect?

回到带有标题的前一页(“Location:”); 在PHP中

这个问题的标题解释了我的问题。 如何将PHP页面访问者redirect回页面header( "Location: URL of previous page" );

redirect到endResponse为真的VS CompleteRequest和安全线程的页面

根据这些问题和答案 ,我想问一下什么是redirect的正确方法。 使用redirect(url,endResponse)的默认方式是抛出ThreadAbortException因为调用endResponse=true调用End()方法,所以,如果你在try / catch块中使用它,这个exception显示在那里 ,被假定为错误,但实际上用户尝试通过停止其余的页面处理来redirect到页面。 其他可能的方式是通过HttpContext.Current.ApplicationInstance.CompleteRequest();来调用Redirect(url, endResponse)并使用endResponse=false HttpContext.Current.ApplicationInstance.CompleteRequest(); 通过使用你没有得到任何例外。 所以问题是什么是更好的使用和为什么。

如何根据cookie值做htaccessredirect

我在Google上失败了,在这里找不到答案。 对不起,我在htaccess上是一个新手,它有很奇怪的语法,很难学! 你可以看到我想在这里做什么… RewriteEngine on RewriteCond %{HTTP_COOKIE} ^.*user_id=(\d+).*$ [NC] RewriteRule .* http://localhost/mysite/cache/$1 [R=301,L] RewriteRule .* http://localhost/mysite/cache/guest [R=301,L] 我正在为每个用户caching页面的加载速度。 我想redirect到正确的HTMLcaching文件夹,如果他们用cookielogin,否则我想加载客户端caching。 现在它进入一个infi循环。 如果我删除[R = …然后我得到内部服务器错误。 请帮忙!!! 谢谢!!!

我只使用脚本的名字在Windows上运行Python脚本时,无法redirect输出

这是运行在Windows 7(64位),Python 2.6与Python的Win32扩展。 我有一个简单的脚本,只是打印“你好世界”。 我可以用python hello.py启动它。 在这种情况下,我可以将输出redirect到一个文件。 但是,如果我通过在命令行上inputhello.py来运行它并redirect输出,我会得到一个exception。 C:> python hello.py hello world C:> python hello.py >output C:> type output hello world C:> hello.py hello world C:> hello.py >output close failed in file object destructor: Error in sys.excepthook: Original exception was: 我想我升级到Windows 7后第一次得到这个错误。我记得它应该在XP中工作。 我看到有人在讨论这个bug python-Bugs-1012692 | 不能pipeinput到python程序 。 但那是很久以前的事了 并没有提到任何解决scheme。 有没有人经历过这个? 任何人都可以帮忙

如何检查标准input是否有一些数据?

在Python中,你如何检查sys.stdin是否有数据? 我发现os.isatty(0)不仅可以检查标准input是否连接到TTY设备,而且如果有数据可用。 但是如果有人使用这样的代码 sys.stdin = cStringIO.StringIO("ddd") 之后使用os.isatty(0) ,它仍然返回True。 我需要做什么来检查标准input是否有数据?