[英]Hidden redirect of / to subfolder using .htaccess in TYPO3
我們正在設置TYPO3安裝,如果用戶調用example.com/,我們希望服務器重定向到/typo/index.php?id=106 。
無需更改地址欄即可完成此操作。 服務器上的所有其他文件訪問(例如example.com/test.png)都應重定向到example.com/typo/test.png。
這是根目錄中的.htaccess文件。 據我了解,它將重定向URL中沒有/ typo的所有內容到子文件夾並附加參數:
RewriteCond %{REQUEST_URI} !^/typo/
RewriteRule ^(.*)$ typo/$1 [L]
現在,當我調用example.com/index.php?id=106時,這似乎已經可以工作了,但是我沒有得到404。不幸的是TYPO3似乎有一些麻煩(或者.htaccess配置不正確),因為我們收到一條消息,提示“未指定輸入文件”。
當沒有指定路徑時,還缺少初始重定向。 然后應轉到/typo/index.php?id=106。
您可以在根目錄的一個.htaccess文件中嘗試此操作:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
# URL with no path
RewriteCond %{REQUEST_URI} ^/?$ [NC]
RewriteCond %{REQUEST_URI} !index\.php [NC]
RewriteRule .* /typo/index.php?id=106 [NC,L]
# URL with path
RewriteCond %{REQUEST_URI} !^/typo [NC]
RewriteRule ^(.+) /typo/$1 [NC,L]
靜默映射:
http://domain.com/
至
http://domain.com/typo/index.php?id=106
和
http://domain.com/anything
http://domain.com/typo/anything
對於永久重定向,將[NC,L]替換為[R = 301,NC,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.