laravel中的URL无法正常工作重定向到找不到的对象

时间:2017-09-09 08:34:08

标签: php laravel .htaccess

我正在开发laravel的网站,但工作正常,但我的网址中存在小问题

我的网址工作正常

http://localhost:8080/JobScholar/contact
http://localhost:8080/JobScholar/index

但是当我在网址末尾使用/

http://localhost:8080/JobScholar/contact/
http://localhost:8080/JobScholar/index/

将我重定向到

http://localhost:8080/index
http://localhost:8080/contact

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

Error 404

localhost
Apache/2.4.26 (Win32) OpenSSL/1.0.2l PHP/7.1.7

的.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
        Options -Indexes
        ErrorDocument 403 http://localhost:8080/JobScholar/index
        Options +FollowSymLinks
    </IfModule>

    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]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

路由

 Route::get('/contact', 'ContactPageController@index');
   Route::get('/index', 'HomePageController@index');

2 个答案:

答案 0 :(得分:0)

尝试在RewriteBase /JobScholar/

之后添加RewriteEngine On

答案 1 :(得分:0)

我不确定,但我认为您需要在.htaccess

中进行更改

来自

RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteRule ^(.*)/$ /JobScholar/$1 [L,R=301]
相关问题