简体   繁体   中英

Install WordPress inside Laravel public folder

I am trying to install WordPress into Laravel public folder. I have completed the installation, but when I am trying to access the same with URL getting WordPress home page without any design.

Please find the .htaccess files of Laravel

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

    RewriteEngine On

    #Exclude url with quora
    RewriteCond $1 !^(quora)

    # 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>

WordPress .htaccess

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

Dont put your wordpress folder inside laravel public's folder, it's a wrong way to do it and can cause problem.

I advise you instead to create 2 folders on the server root, one with laravel and one with wordpress.

Then to access to wordpress from laravel you have two choice,

  1. use a subdomain (wordpress.exemple.com)
  2. create an alias (exemple.com/wordpress)

I think what your looking for is the alias so

to create the alias, create a new apache conf but instead of using server property, use alias property

Alias /wordpress /var/www/wordpress/

<Directory "/var/www/wordpress/">
    //here your directory conf
</Directory>

enable the conf in apache, restart the server and now, on laravel when you go to the route /wordpress you're on wordpress.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM