如何在共享主机godaddy服务器上为子域设置.htaccess

时间:2017-07-06 04:25:33

标签: laravel .htaccess laravel-5

我想在godaddy上传我当地的Laravel项目,但我有一些错误

错误

[Wed Jul 05 21:16:44.858396 2017] 
    [autoindex:error] [pid 21796:tid 139689709188864] 
    [client 99.240.235.234:57754] 
    AH01276: 
        Cannot serve directory /home/bugsbunny/public_html/sto.com/: 
            No matching DirectoryIndex (/home/bugsbunny/public_html/sto.com/public/index.php) 
    found, and server-generated directory index forbidden by Options directive

的.htaccess

DirectoryIndex /home/bugsbunny/public_html/sto.com/public/index.php
<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </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 ^ /home/bugsbunny/public_html/sto.com/public/index.php [L]

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

我做的步骤

  • 我编辑了public / .htaccess文件
  • 编辑后我的意思是更改第一行上的目录和以RewriteRule
  • 开头的行
  • 我切割&amp;将此文件粘贴到根目录
  • 我将项目上传到godaddy

2 个答案:

答案 0 :(得分:0)

在Godaddy上,我发现使用此程序创建/上传Laravel应用程序更容易

1- Create an addon domain or a sub-domain on Godaddy
2- Install a Laravel app (Quick-install) on this domain/sub-domain
3- Download this app on local (my computer) with Filezilla (or other sftp software)
4- On local disk change the .env database access or (create a user+password+database on phpmyadmin/mysql with the information contain in the .env that Godaddy setup for you)
5- finish up the app (Build the webapp project that you want to do).
6- Upload the app to the server (except the .env) with Filezilla
7- upload the database (mysql) from local to Godaddy

因此无需更改.htaccess文件。

答案 1 :(得分:-1)

为什么你没有使用专用主机进行laravel。获取您的服务器和[digitaloccean等],做你想做的......