Live server not working well in Laravel Contact Us
P粉495955986
2023-09-03 22:13:10
<p>My local Laravel project is running fine. But after hosting the project with a live server, it's working fine except for the contact us form.
This is my contact form</p>
<pre class="brush:php;toolbar:false;"><div class="content">
@include('partials.alerts')
<h1 class="heading">Contact Us</h1>
<form method="post" action="{{url('form')}}#contact">
{{csrf_field()}}
<div class="form">
<div class="input-flex">
<input type="text" name="name" placeholder="Name*" /><br><br>
<span style="color:red">@error('name'){{$message}}@enderror</span>
<input type="email" name="email" placeholder="E-mail*" /><br><br>
<span style="color:red">@error('email'){{$message}}@enderror</span>
<input type="tel" class="full-width" name="telephone" placeholder="Phone number*" /><br><br>
<span style="color:red">@error('telephone'){{$message}}@enderror</span>
<textarea cols="2" rows="2" class="full-width" name="message" placeholder="Message"></textarea>
</div>
<button class="conbtn" type="submit">Submit</button></pre>
<p>我的联系人滚动导航是</p>
<pre class="brush:php;toolbar:false;"><nav class="navbar">
<a href="#contact">contact</a>
</nav></pre>
<p>联系我们的控制器是</p>
<pre class="brush:php;toolbar:false;">protected function store(Request $request)
{
//validate request
$this->validate($request,[
'name' => 'required|max:100',
'email' => 'required|email',
'telephone' => 'required',
]);
$user = new User;
$user->name = $request->input('name');
$user->email = $request->input('email');
$user->telephone = $request->input('telephone');
$user->message = $request->input('message');
$user->save();
$verifyUser = VerifyUser::create([
'user_id' => $user->id,
'token' => Str::random(40)
]);
Mail::to($user->email)->send(new VerifyMail($user));
return redirect('/#contact')->with('info', 'We sent you an activation code. Check your email and click on the link to verify');
}</pre>
<p>我的联系我们验证消息和验证消息在提交提交按钮后重定向到联系部分。这个系统在我的本地机器上运行良好。但在实时服务器中收到以下错误消息
<code>抱歉,该页面不存在。请检查 URL 或返回页面。 404 错误。找不到页面。</code></p>
<p>提交联系表单后,我可以监控本地和实时服务器中是否有不同的网址
本地主机就像 <code>http://localhost:8000/#contact</code></p>
<p>但是实时服务器就像<code>https://academi.com/form#contact</code></p>
<p>我对此感到困惑。我该如何解决这个问题</p>
I will check your server configuration. If it works locally but not on the live server, there may be a problem. Check that your apache/nginx configuration matches, especially in terms of rewriting urls