【问题标题】:Laravel: Setup .htaccess of Folder outside of Laravel AppLaravel:在 Laravel 应用程序之外设置文件夹的 .htaccess
【发布时间】:2014-09-15 17:50:04
【问题描述】:

我在/var/www/html 中安装了 Laravel

我在/var/www/html/i/ 中安装了一个 PHP 脚本

/var/www/html/的htaccess是

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

/var/www/html/i/的htaccess是

<IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteRule ^(.+)$ /?variable=$1

</IfModule>

麻烦就是每次去

/i/somevariable

我的 laravel 应用程序出现 404 错误。

【问题讨论】:

  • 什么网络服务器?您需要使用重写规则,并且每个网络服务器的规则都不同。
  • apache,我打开了 mod_rewrite

标签: php apache mod-rewrite laravel-4


【解决方案1】:

如果你使用的是 apache 读取 mod_rewrite http://httpd.apache.org/docs/current/mod/mod_rewrite.html

不要只是打开, 使用重写规则

【讨论】:

【解决方案2】:

在您的根文件夹中创建一个包含以下内容的 .htaccess 文件:

RewriteEngine On    # Turn on the rewriting engine
RewriteRule    ^([A-Za-z0-9-]+)/i/?$    index.php/i/?s=$1    [NC,L] 

这应该可以正常工作。

【讨论】:

  • RewriteEngine On RewriteRule ^([A-Za-z0-9-]+)/i/?$ index.php/i/?s=$1 [NC,L] # 重定向尾部斜杠。 .. RewriteRule ^(.*)/$ /$1 [L,R=301] # 处理前端控制器... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L]
猜你喜欢
  • 2022-10-13
  • 1970-01-01
  • 2022-10-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多