只能访问Laravel 5.2中的/ route

时间:2017-07-26 07:54:10

标签: php apache laravel amazon-ec2 apache2

我只能访问' /'路线和我所有其他路线都返回404。

我在新的EC2实例上安装了laravel,我确保我的php,Mysql和apache2都在运行

我的Laravel版本是5.2.45

我的000-default.conf如下

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/testing/public

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

我的apache2.conf文件如下

<Directory />
        Options FollowSymLinks
        AllowOverride None
        Require all denied
</Directory>

<Directory /usr/share>
        AllowOverride None
        Require all granted
</Directory>

<Directory /var/www/html/testing/public>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

我的文件夹结构是/ var / www / html / testing

但是当我试图击中ip时我得到500.任何帮助将受到高度赞赏。

routes.php文件

**********Physiotherapist******/
Route::get('/home-request/physiotherapist', 'HomeController@physiotherapist');
Route::post('/physiotherapist', 'ServicesController@requestPhysio');
Route::post('/physiotherapist/getPhysioRates', 'ServicesController@getPhysioRates');

/********** Doctor *************/
Route::get('/home-request/doctor', 'HomeController@doctor');
Route::post('/doctor', 'ServicesController@requestDoctor');
Route::post('/doctor/getDoctorRates', 'ServicesController@getDoctorRates');

/********** Patient Attendant *************/
Route::get('/home-request/patient-attendant', 'HomeController@patient');
Route::post('/patient', 'ServicesController@requestAttendant');
Route::post('/patient/getPatientAttendantRates', 'ServicesController@getPatientAttendantRates');

/public/.htaccess文件

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

Options -Indexes


RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^([^\.]+)$ $1.php [NC,L]
# RewriteRule ^([^\.]+)/([^\.]+)$ /$2.php  [L] 
    # 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>

<ifmodule mod_expires.c>
  ExpiresActive On
  AddType image/x-icon .ico
  ExpiresByType image/gif "access plus 60 days"
  ExpiresByType image/jpeg "access plus 60 days"
  ExpiresByType image/png "access plus 60 days"
  ExpiresByType image/ico "access plus 60 days"
  ExpiresByType image/x-icon "access plus 60 days"
  ExpiresByType text/css "access plus 60 days"
  ExpiresByType application/javascript "access plus 60 days"
  ExpiresByType application/x-javascript "access plus 60 days"
  ExpiresByType text/javascript "access plus 60 days" 
  ExpiresByType application/json "access plus 7 minutes" 
</ifmodule>
## EXPIRES CACHING ##


<IfModule mod_deflate.c>
  # Compress HTML, CSS, JavaScript, Text, XML and fonts
  AddOutputFilterByType DEFLATE application/javascript
  AddOutputFilterByType DEFLATE application/rss+xml
  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
  AddOutputFilterByType DEFLATE application/x-font
  AddOutputFilterByType DEFLATE application/x-font-opentype
  AddOutputFilterByType DEFLATE application/x-font-otf
  AddOutputFilterByType DEFLATE application/x-font-truetype
  AddOutputFilterByType DEFLATE application/x-font-ttf
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE font/opentype
  AddOutputFilterByType DEFLATE font/otf
  AddOutputFilterByType DEFLATE font/ttf
  AddOutputFilterByType DEFLATE image/svg+xml
  AddOutputFilterByType DEFLATE image/x-icon
  AddOutputFilterByType DEFLATE text/css
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/xml
    Header append Vary User-Agent
</IfModule>

1 个答案:

答案 0 :(得分:1)

您需要在您的appache conf中允许覆盖。试试这个:

<Directory /var/www/html/testing/public>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>