簡體   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