![](/img/trans.png)
[英]htaccess - redirect everything to index.php except a folder and specific files
[英]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.