简体   繁体   English

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

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

Situation 情况

I am trying to redirect all my traffic to the index.php file one level above root, for example: 我试图将所有流量重定向到根目录上一级的index.php文件,例如:

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

This and it works using the rules defined below 这和它使用下面定义的规则一起工作

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

Problem 问题

The above works without issue but...If I try going to 上面的作品没有问题,但是...如果我尝试去

lala.com/this

I get sent back to lala.com. 我被送回lala.com。 Can someone please offer me a quick pearl of wisdom here. 有人可以在这里为我提供智慧的明珠。 Thank you kindly for reading my question 谢谢您阅读我的问题

Attempt 尝试

I have tried the following 我尝试了以下

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

This may be due to the RewriteBase whitch is defined to /this/. 这可能是由于RewriteBase提示定义为/ this /。 Try this modification : 试试这个修改:

<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