【问题标题】:htaccess file edit to use laravel and php website same timehtaccess 文件编辑以同时使用 laravel 和 php 网站
【发布时间】:2021-03-16 12:25:53
【问题描述】:

我的共享主机空间文件排列如下

#root > public_html > [extracted laravel public folder]
#root > public_html > Project1 > [php project file]
#root > public_html > Project2 > [wordpress project file]
#root [Laravel project rest of the files]
#root > public_html > .htaccess file

我需要显示如下页面

www.domain.com [laravel project]
www.domain.com/contact [same laravel project contact us page]
www.domain.com/project1 [php new project]
www.domain.com/project2 [wordpress website project]

要完成这项工作,我需要编辑 root > public_html > .htaccess 文件,但我不知道该怎么做。这是我当前的文件。你能帮我解决这个问题吗

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

    RewriteEngine On
     RewriteRule ^project1 /project1/index.php [L]
    # 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>

【问题讨论】:

  • 您能否以 from url(browser) 的形式发布链接,该链接将在后端为它们提供服务,以便更好地理解您的问题。

标签: laravel .htaccess hosting


【解决方案1】:

您提供的信息有点缺乏,但这里是我对您所问问题的最佳猜测的解决方案。

##############.htaccess file #################
<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]

# Redirect all requests to ^/project-1/.* to the WordPress front controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/project-1/
RewriteRule ^ /project-2/index.php [L]

# Assuming your new PHP project also has a front controller 
# Redirect all requests to ^/project-2/.* to the new PHP project front controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/project-2/
RewriteRule ^ /project-2/index.php [L]


#Redirect all requests to ^/.*, but not ^/project-1/.* and not ^/project-2/.*
# to the Laravel front controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/project-1/
RewriteCond %{REQUEST_URI} !^/project-2/
RewriteRule ^ index.php [L]
</IfModule>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-02-26
    • 2010-10-09
    • 2018-05-11
    • 1970-01-01
    • 1970-01-01
    • 2021-12-22
    • 2017-04-11
    相关资源
    最近更新 更多