iT邦幫忙

1

佈署到雲端主機後,網頁只能開首頁,其他網頁都404

  • 分享至 

  • xImage

請教一下前輩們!
我的一個Laravel項目在開發環境都ok,但佈署到雲端主機後卻只能顯示首頁,點其他網頁都:

網頁上出現:
Not Found
The requested URL was not found on this server.
Apache/2.4.41 (Ubuntu) Server at i58d.com Port 443

console控制台則出現:
GET https://***.com/register 404 (Not Found)

是我的apache2/site-available/檔案寫錯嗎?

我的/etc/apache2/sites-available/***.conf 如下:

<VirtualHost *:80>
    ServerName ***.com
    ServerAlias www.***.com
    ServerAdmin id****e@gmail.com.com
    DocumentRoot /var/www/***/public

    <Directory /var/www/***/public>
        Options -Indexes +FollowSymLinks
        AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/***.com-error.log
    CustomLog ${APACHE_LOG_DIR}/***.com-access.log combined
 </VirtualHost>

我的/etc/apache2/sites-available/***-ssl.conf 如下:

<IfModule mod_ssl.c>
        <VirtualHost *:443>
                ServerAdmin id***@gmail.com

                DocumentRoot /var/www/***/public
                ServerName ***.com
                ServerAlias www.***.com


                ErrorLog ${APACHE_LOG_DIR}/***_error.log
                CustomLog ${APACHE_LOG_DIR}/***_access.log combined

                SSLEngine on

                SSLCertificateFile      /etc/letsencrypt/live/***.com/fullchain.pem
                SSLCertificateKeyFile /etc/letsencrypt/live/***.com/privkey.pem

                #<FilesMatch "\.(cgi|shtml|phtml|php)$">
                #       SSLOptions +StdEnvVars
                #</FilesMatch>

                #<Directory /usr/lib/cgi-bin>
                #       SSLOptions +StdEnvVars
                #</Directory>
        </VirtualHost>
</IfModule>

煩請前輩幫我看一眼,我哪裡有錯誤?

這一段這麼寫
<Directory /var/www/***/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
然後
sudo /etc/init.d/apache2 restart
謝謝指教,再請教下:

443不用只寫在80裡面就可以是嗎?

<VirtualHost *:80>
<Directory /var/www/***/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
可以了!真是感謝!
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友回答

立即登入回答