且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

WordPress项目旁边的Laravel项目(在public_html文件夹中)

更新时间:2022-11-04 19:53:53

您可以在Laravel文件夹中创建符号链接到Wordpress公共目录。例如, wp

You can create symlink to Wordpress public directory in Laravel folder. For example, wp:

/var
     /www
         /laravel
             /public
                 /wp #(symlink to -> /var/www/wordpress/public_html)
                 index.php
                 .htaccess
         /wordpress
             /public_html
                 index.php
                 .htaccess

并在.htaccess中描述Laravel路线。代码示例 /var/www/laravel/public/.htaccess

And describe Laravel routes in .htaccess. Example of code of /var/www/laravel/public/.htaccess:

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

    RewriteEngine On

    RewriteCond %{ENV:REDIRECT_FINISH} .
    RewriteRule ^ - [L]

    # Laravel

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteCond %{REQUEST_FILENAME} !.*\.php$
    RewriteRule ^(.*)$ $1 [E=FINISH:1,L]

    RewriteCond %{REQUEST_URI} ^/(api/licenseplate)(\?.*|$) [OR]
    RewriteCond %{REQUEST_URI} ^/(api/calendar)(\?.*|$) [OR]
    RewriteCond %{REQUEST_URI} ^/(admin/settings)(\?.*|$) [OR]
    RewriteCond %{REQUEST_URI} ^/(admin/appointments)(\?.*|$) [OR]
    RewriteCond %{REQUEST_URI} ^/(appointment)(\?.*|$) [OR]
    RewriteCond %{REQUEST_URI} ^/(auth/login)(\?.*|$)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [E=FINISH:1,L]

    # Wordpress

    RewriteCond %{REQUEST_URI} !^/wp
    RewriteRule ^(.*)$ /wp/$1 [E=FINISH:1,L]

</IfModule>

代码 /var/www/wordpress/public_html/.htaccess (只是你的wordpress .htaccess的副本):

Code of /var/www/wordpress/public_html/.htaccess (just copy of your wordpress .htaccess):

# BEGIN WordPress

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>

# END WordPress