【发布时间】:2017-05-22 01:30:17
【问题描述】:
当我尝试像
这样点击 url 时,我遇到了一个奇怪的问题www.mywebsite.com/walkthrough?hostid=12345
它会自动在'之前附加'/'?'在网址中。 喜欢
www.mywebsite.com/walkthrough/?hostid=12345
因此我无法获取参数 hostid。
路线
Route::get('/walkthrough', ['uses' => 'WalkthroughController@index']);
HTACCESS
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options -Indexes
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
#php_value allow_url_fopen 0
#php_value allow_url_include 0
</IfModule>
为什么会这样?非常感谢任何帮助..谢谢。
【问题讨论】:
-
你能显示你的代码和路线吗?
-
添加路线..请检查问题。
-
如果你用
Route::get('/walkthrough/{step}', ['uses' => 'WalkthroughController@index2'])添加另一条路线,你可以得到hostidpublic function index2($hostid) {} -
这很奇怪。尝试按照我在下面的答案中提到的定义路线。
-
项目的要求是url应该按照我上面问题www.mywebsite.com/walkthrough?hostid=12345中显示的方式使用
标签: php laravel url laravel-5 routes