.htaccess . htaccess将不存在的文件重定向到文件夹中的index.php,文件名为参数

unguejic  于 7个月前  发布在  PHP
关注(0)|答案(1)|浏览(88)

我有以下.htaccess重写规则:

RewriteEngine On
RewriteBase /app/

RewriteCond %{THE_REQUEST} \s/app/index\.php\?view=([^&\s]+) [NC]
RewriteRule ^ %1? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)$ index.php?view=$1 [L]

在过去,这是一个很好的重定向:

  • website.com/app/whatever*

  • website.com/app/index.html?view=whatever*

现在,由于我们新的测试结构,Web应用程序将移动到动态文件夹,例如:

  • website.com/bbb/app/whatever*

我的RewriteRule没有正确地将其重定向到

  • website.com/website/bbb/app/index.html?view=whatever*

我也有以下文件夹结构:

root
- app
-- index.php
-- .htaccess

- folder1
-- index.php
-- .htaccess

-index.php
-.htaccess

子文件夹中的.htaccess文件基本上都是一样的,只是“/app/”被替换为,例如,“folder 1”。可能有一个更好的方法在一个htaccess中完成所有这些。

bbmckpt7

bbmckpt71#

多亏了Arkascha,我找到了这个问题。
重写基地的道路我看不见。
这一方法:

RewriteBase /f1/f2/app/

相关问题