大网数据广告活动
网站运营与故障问答

my laravel sub-domain urls does not work except homepage

· 52CE 我爱测

I am new to hosting web apps online. I wanted to host an app in my subdomain eg departmennt1.example.com . I added the subdomain in cPanel. Located its directory in file manager. It happens that the subdmain is also a folder in t…

问题原文

原帖链接 · Othman · CC BY-SA 4.0

I am new to hosting web apps online. I wanted to host an app in my subdomain eg departmennt1.example.com. I added the subdomain in cPanel. Located its directory in file manager. It happens that the subdmain is also a folder in the root directory. I upload the locally working site in the subdomain folder. After setting up my database on the .env folder. I also ensure that my public folder files were inside the subdomain folder. I ensure that the app and the autoload.php in index.php file in the subdomain folder is pointing correctly to the vendor and boostrap folder.

After that, I tried loading the subdomain address in the browser, but only the index page ie.

Route::get('/', function () {
    return view('welcome');
});

any other URL will return like login will show

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I tried it on another hosting company where the subdomain by default resides in the public_html directory and everything worked out fine.

How can I host at the first hosting company?

已采纳解答

原帖链接 · Othman · CC BY-SA 4.0

I was able to solve the whole problem by changing my .htaccess file from

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-ea-php72 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

to

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

    RewriteEngine On

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

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

I dont know what the code above does. I'll love it to get explation for the greater good of all

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2020-07-22)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。