How to install wordpress in laravel public folder

白昼怎懂夜的黑 提交于 2020-06-15 07:37:46

问题


i also follow this link but this is not my solution - laravel and wordpress on the same domain(laravel in subfolder)
i want to add wordpress in my laravel site.
so i install all wordpress in my laravel's public folders. here i create one folder "blog" and in this folder i install my wordpress site.

but my problem is when i run my wordpress site like that localhost:8000/blog it work fine

But when i am try to oprn another link then laravel redirect me 404 page not found.

so how to run wordpress in laravel if make any changes in any file so please any one help me.

my laravel public folder's .htaccess look like that

<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 ^ index.php [L]

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


回答1:


To run wordpress as subdirectory, you must change the .htaccess file inside worpress directory like below:

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

Follow this guide for more information https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory




回答2:


Well that quite simple if you have a laravel application such as laravel. What you have to do is just:

  1. download wordpress form wordpress.org

  2. rename that downloaded wordpress folder to any name such as blog

  3. put that blog folder into a public directory of laravel

  4. put database credential of wordpress blog into wp-config.php

  5. as well as put laravel db credential in .env

  6. make change in .htaccess of laravel

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} http://localhost/laravel/public/$
    RewriteCond %{REQUEST_URI} !^/blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /blog/$1
    RewriteCond %{HTTP_HOST} http://localhost/laravel/public/$
    RewriteRule ^(/)?$ blog/index.php [L] 
    </IfModule>
    
  7. You can easily access your blog as http://localhost/laravel/public/blog

  8. It will start wordpress blog



来源:https://stackoverflow.com/questions/44347249/how-to-install-wordpress-in-laravel-public-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!