如何在laravel中使用.htaccess

时间:2016-08-09 04:18:39

标签: laravel

我在我的主人中创建了一个目录:

www.mysite.com/test/

我已将我的laravel文件夹复制到其中。但是当我在浏览器上调用该URL时,它会向我显示:

enter image description here

我想我应该制作.htaccess

4 个答案:

答案 0 :(得分:0)

以下是我案例和案例的示例: -

我的案例: -

URL Before .htaccess www.xyz.com/public/index.php
URL After .htaccess www.xyz.com

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* public/index.php [L]

你的案子: -

URL Before .htaccess www.xyz.com/test/public/index.php
URL After .htaccess www.xyz.com

Options +FollowSymLinks
RewriteEngine On


RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* test/public/index.php [L]

答案 1 :(得分:0)

Laravel应用程序位于/ public文件夹中,该文件夹也已有.htaccess:INSERT INTO public.contributor (name, commits, image, library, owner) SELECT owner_name, 1, owner_image, library, owner FROM public.commit WHERE id = 'e3c8a92a-64c7-408a-baa4-d80f47c3d3c3' ON CONFLICT (owner, library) DO UPDATE SET commits = (contributor.commits + 1)

您可以做的是将mysite.com/public/test文件夹符号链接到公共目录。例如:

project/public

现在,您应该可以在ln -s /path/to/project/public /var/www 上看到该应用。

This article部署Laravel 5应用程序可能会有所帮助。

答案 2 :(得分:0)

在     的.htaccess 文件已经存在于公用文件夹中,您需要配置的是您的服务器

for Linux on terminal execute:

cd /etc/apache2/sites-available
/etc/apache2/sites-available$ sudo vi myapp.conf

添加/修改这些行以适合您的服务器

<VirtualHost *:80>
ServerName myapp.localhost.com
DocumentRoot "/home/vagrant/projects/myapp/public"
<Directory "/home/vagrant/projects/myapp/public">
AllowOverride all
</Directory>
</VirtualHost>

保存文件,然后继续下面。

/etc/apache2/sites-available$ cd ../sites-enabled
/etc/apache2/sites-enabled$ sudo ln -s ../sites-available/myapp.conf
/etc/apache2/sites-enabled$ sudo service apache2 restart

对于Laravel根文件夹中的Windows服务器,添加web.config文件并在其中写入这些代码

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
    <defaultDocument>
        <files>
            <clear />
            <add value="index.php" />
            <add value="default.aspx" />
            <add value="Default.htm" />
            <add value="Default.asp" />
            <add value="index.htm" />
            <add value="index.html" />
        </files>
    </defaultDocument>
    <handlers accessPolicy="Read, Execute, Script" />
    <rewrite>
        <rules>
            <rule name="Imported Rule 1">
                <match url="^(.*)$" ignoreCase="false" />
                <action type="Rewrite" url="/public/{R:1}" />
            </rule>
            <rule name="Imported Rule 2" stopProcessing="true">
                <match url="^(.*)$" />
                <conditions logicalGrouping="MatchAll">
                    <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                    <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                </conditions>
                <action type="Rewrite" url="public/index.php/{R:1}" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

答案 3 :(得分:-1)

在laravel的根目录中创建一个<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_URI}!^public RewriteRule ^(.*)$ public/$1 [L] </IfModule> 文件。这是为了在没有&#34; public&#34;在网址上

The default password meets the password policy. So this should be a permission issue.
In the previous "Database Server" tab, did you use the DB admin user to login? If you used admin user, you can create a new connection in Oracle SQL Developer and try below queries to test the permission.

create user "<Schema_name>" IDENTIFIED by "<Schema_password>" DEFAULT TABLESPACE "<Default_Tablespace>" TEMPORARY TABLESPACE "<Temporary_Tablespace>" PROFILE DEFAULT;
GRANT CREATE VIEW TO "<Schema_name>";
GRANT CREATE TABLE TO "<Schema_name>";
GRANT CREATE SESSION TO "<Schema_name>";
GRANT CREATE TRIGGER TO "<Schema_name>";
GRANT CREATE SEQUENCE TO "<Schema_name>";
GRANT CREATE PROCEDURE TO "<Schema_name>";