我正在尝试在我的一个控制器中发出redirect_to到一个完全限定的URL +我想传递一些参数
在网站AI的控制器中:
redirect_to: "www.siteB.com/my_controller/my_action?my_parameter=123"
Run Code Online (Sandbox Code Playgroud)
在rails中有更好的方法吗?
ruby ruby-on-rails http-status-code-301 http-status-code-302
我已经设置了自定义404页面custom404.aspx,它正确地返回"404 Not Found"错误,但是最初请求的不存在的页面返回"302 Found"状态.
因此,当我测试thispagedoesnotexist.aspx时,它返回"302 Found",然后custom404.aspx加载并返回"404 Not Found"状态.
我想确保搜索蜘蛛/机器人了解所请求的页面不存在且不应出现在任何搜索结果中.这个设置是否正确?
我想要做的是捕获302错误,这意味着用户没有登录,然后将该用户重定向到网站的登录页面.这是我的backbone.js同步覆盖现在:
parentSynchMethod = Backbone.sync
Backbone.sync = (method, model, success, error) ->
try
parentSynchMethod.apply(Backbone, arguments)
catch error
window.location.replace("http://localhost:8080/login")
Run Code Online (Sandbox Code Playgroud)
302肯定会发生错误,当我使用谷歌浏览器检查页面时,我可以在网络视图中看到它.但是,当我设置断点时,它永远不会进入catch,并且error参数未定义.这是因为302不是真正的错误(当我查看响应的状态时它是黄色的,而不是通常的红色表示错误,或者我在某处弄乱了代码.
我读了这个问题,知道HTTP中301和302有什么区别,但我的问题是搜索引擎的HTTP中301和302有什么区别?
我已经尝试了一切,我接近放弃了.请帮忙.
我一直试图摆脱codeigniter中的index.php并完成了谷歌提供的每个代码以放入.htaccess.
目前,我有这个.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
Run Code Online (Sandbox Code Playgroud)
这确实有效,但每次我提交表格时,我都会收到这个令人抓狂的错误的302错误.

我控制器中的一个提交功能......其他形式的其他功能基本相同.我已经尝试了刷新和重定向的定位方法,既没有改变任何东西.我不相信这是问题所在.
public function submitStory(){
if (empty($this->user)) {
redirect('/home/');
}else{
$this->story_model->writeStory();
redirect('story/newChapterView/');
}
Run Code Online (Sandbox Code Playgroud)
}
我的模型只是插入数据库
public function writeStory(){
$this->title = strip_tags($this->input->post('wTitle'));
$this->date = time();
$this->author = strip_tags($this->input->post('wAuthor'));
$this->type = strip_tags($this->input->post('wType'));
$this->db->insert('story_tbl', $this);
}
Run Code Online (Sandbox Code Playgroud)
我的一个表单,它们几乎只是一个标准的codeigniter表单
<?=form_open('story/submitStory', array('id' => 'newStory'));?>
<p class="textBox"><label>Story Title: </label><input id="storyTitle" type="text" name="wTitle" autocomplete="off" /></p>
<p><label>Complete:</label><select class="drop" …Run Code Online (Sandbox Code Playgroud) Passport.js 能够在身份验证时提供成功和失败重定向 URL:
app.post('/login',
passport.authenticate('local', { successRedirect: '/success.html',
failureRedirect: '/failed.html'
}
);
Run Code Online (Sandbox Code Playgroud)
据我所知,重定向始终是“302 Found”——但是它们不应该是“303 See Other”吗?因为根据RFC 2616/10.3.3
如果收到 302 状态代码来响应除
GET 或 HEAD 之外的请求,则用户代理不得自动重定向
请求,除非用户可以确认该请求[...]
注意:我看到 stackoverflow 也回复了 302 登录,因此这可能是一种广泛且可以容忍的违规行为。
预先感谢您的任何评论或建议。
我有一个脚本,它使用大量 cURL 来登录站点并提交一系列表单,但是由于 cURL 请求返回 302 并重定向到块/端点页面,该脚本最近停止工作。如果我使用浏览器执行相同的操作,则不会出现重定向,只有 200 OK。
我的 cURL 使用登录过程返回的 cookie,因此我认为会话不会被删除。
我最初认为在给定重定向位置的情况下缺少 CSRF 令牌(某种),并且流程中的后续表单(使用浏览器)包含隐藏的 CSRF 令牌字段,但 URL 不需要发布数据。
cURL 和响应如下:
curl_setopt($ch, CURLOPT_URL, 'https://*******.********.co.uk/Dispatcher?menuid=pos_home');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_HEADER, 0);
$content = curl_exec ($ch);
echo "CURL INFO : <BR/><pre>" ;
print_r(curl_getinfo($ch));
Run Code Online (Sandbox Code Playgroud)
返回:
Array
(
[url] => https://*******.********.co.uk/Dispatcher?menuid=pos_home
[content_type] => text/html
[http_code] => 302
[header_size] => 253
[request_size] => 332
[filetime] => -1
[ssl_verify_result] => 20
[redirect_count] => 0
[total_time] => 0.142718
[namelookup_time] => 2.4E-5
[connect_time] => 2.4E-5
[pretransfer_time] …Run Code Online (Sandbox Code Playgroud) 我在Ruby上运行我的Rails后端,我想将数据发布到此服务器.但如果我用PAW做一个Post-request,我会被重定向.我是Http Requests的新手.有人可以解释我的功能以及如何使用http post请求吗?
我想在我的服务器的datanase(sqlite3)上发布信息.
这是如何运作的?请解释:)谢谢.问候约翰
这是代码:
OwnersController:
#app/controllers/owners_controller.rb
class OwnersController < SessionsController
respond_to :html
before_action :owner_find, only: [:show, :edit, :update, :destroy]
def index
@owners = Owner.all
end
def show
end
def update
@owner = Owner.find(params[:id])
if @owner.update(owner_params)
redirect_to @owner
else
render 'edit'
end
end
def new
@owner = Owner.new
end
def destroy
@owner.destroy
redirect_to owners_path
end
def edit
end
def create
@owner = Owner.new owner_params
if @owner.save!
flash[:notice] = 'You signed up successfully'
flash[:color]= 'valid'
redirect_to owners_path
else
flash[:notice] …Run Code Online (Sandbox Code Playgroud) 我已经看到了HTTP 重定向图像是否可以的答案。这是一个 YES - 浏览器将遵循重定向。
但是,电子邮件客户端(GMail、Express、Thunderbird、Yahoo...)是否遵循相同的规则?
我正在用 php 创建一个简单的问答留言板。当有人提交问题的答案时,php 脚本会将用户重定向到原始问题,并在页面底部显示更新的答案。
\n\n在这种情况下,使用 301、302 或 303 重定向会更好吗?我正在考虑 302 重定向,因为重定向不是永久的或静态的 \xe2\x80\x93 重定向取决于发送到提交脚本的参数。不过,我也看到某些表格推荐使用 303。
\nphp forms redirect http-status-code-301 http-status-code-302
redirect ×4
php ×3
http ×2
asp.net ×1
backbone.js ×1
codeigniter ×1
coffeescript ×1
curl ×1
email-client ×1
express ×1
forms ×1
node.js ×1
passport.js ×1
post ×1
ruby ×1
seo ×1
sync ×1