Laravel重定向到错误的网址

时间:2016-07-12 19:45:46

标签: wordpress .htaccess laravel

我的项目有Wordpress和Laravel

Wordpress网址 http://localhost/aaa
Laravel项目网址 http://localhost/aaa/bbb

当我通过http://localhost/aaa/bbb/访问Laravel时工作正常 但没有/最终像http://localhost/aaa/bbb它重定向我 http://localhost/bbb

这是Wordpress文件中的htaccess

RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/?bbb/.*$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{REQUEST_URI} ^/?bbb/?$
RewriteRule . /bbb/public/index.php [L]

这是Laravel项目中的htaccess

<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 ^(.*)/$ /public/$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}]

Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

任何想法?

2 个答案:

答案 0 :(得分:0)

我说...

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^aaa/(.*)/$ /public/$1 [L,R=301]

答案 1 :(得分:0)

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

RewriteEngine On

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

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

您可以在laravel htaccess

中尝试此操作