繁体   English   中英

htaccess。 一切都在index.php的一个级别中。除了我要重定向到的内容,其他都可以工作

[英]htaccess. Everything to index.php one level in. Works except what I want to redirect to

情况

我试图将所有流量重定向到根目录上一级的index.php文件,例如:

lala.com/this/who/
lala.com/this/knew/it
lala.com/this/hello/
lala.com/this/would/be/so/annoying

这和它使用下面定义的规则一起工作

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /this/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php? [L]
</IfModule>

问题

上面的作品没有问题,但是...如果我尝试去

lala.com/this

我被送回lala.com。 有人可以在这里为我提供智慧的明珠。 谢谢您阅读我的问题

尝试

我尝试了以下

RewriteCond %{REQUEST_URI} !^/this
RewriteRule ^this - [L,NC]
RewriteCond $1 !^(this)

这可能是由于RewriteBase提示定义为/ this /。 试试这个修改:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ this/index.php? [L]
</IfModule>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM