Install Wordpress with Laravel in same domain in f

2019-02-15 08:34发布

问题:

I have a laravel installation at same domain.com. The site is up and running. I need to install a wordpress in blog folder at domain.com/blog. when I try to install the wordpress, it's not allowing me to run the installation and says "This webpage has a redirect loop" . I installed wordpress by using domain.com/blog/index.php, But after installation I was not able to run the wordpress blog from domain.com/blog/

I have provided relevant permissions to the wordpress blog folder.I will be managing wordpress from the blog admin and laravel site from laravel section.

I have seen https://laracasts.com/discuss/channels/general-discussion/install-wordpress-in-domaincomblog but could not make it work.

Mu working environment is : Xampp in Ubuntu

Any suggestions will be helpful.

回答1:

I got a solution from laravel forum. Adding the line in the htaccess worked for me.

RewriteCond $1 !^(blog)

Blog is working properly as a separate folder.



回答2:

this line in .htaccess is probably your culprit:

RewriteRule .*/$ /$1 [L,R=301]

comment it out and see it that solves your problem.

This line forces everything in the public domain to go through laravel's router. You could probably leave it by writing another regex above that line looking specifically for the /blog directory, or rewrite that line to route anything that != your blog directory.

You should really leave that line there if possible.



回答3:

Add below lines in .htaccess

RewriteCond $1 !^(bmcblog)

 # Redirect Trailing Slashes...
 RewriteRule ^(.*)/$ /$1 [L,R=301]

It will look like this

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

    RewriteEngine On

    RewriteCond $1 !^(bmcblog)
    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # 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}]
</IfModule>