2013-03-20 39 views
0

我們正在建立一個TYPO3安裝,如果用戶調用example.com/我們想在服務器中使用的.htaccess到子文件夾重定向到/typo/index.php ?id = 106的隱藏重定向/ TYPO3的

這應該發生在地址欄沒有變化。服務器上的其他文件訪問權限(例如example.com/test.png)應該重定向到example.com/typo/test.png)。

這是根目錄中的.htaccess文件。據我瞭解,它會重定向不具有一切/ URL中的子文件夾錯字並附加參數:

RewriteCond %{REQUEST_URI} !^/typo/ 
RewriteRule ^(.*)$ typo/$1 [L] 

現在,這似乎已經工作,當我打電話example.com/ index.php?id = 106我沒有收到404錯誤。不幸的是,TYPO3似乎有些麻煩(或.htaccess配置不正確),因爲我們收到一條消息:「沒有指定輸入文件」。

還缺少什麼是沒有指定路徑時的初始重定向。它應該去/typo/index.php?id=106。

回答

7

您可以在一個.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

對於永久重定向,與[R = 301,NC,L]

+0

我們會嘗試一下:)會讓你知道會發生什麼替換[NC,L]。 – Ahatius 2013-03-20 08:20:08

+0

這看起來像另一個選項不在我的答案:當請求是這樣的'http://domain.com/index.php?id = 999'它會默默地映射到'http://domain.com/typo/的index.php?ID = 999'?我的答案中的其他選項是否按預期工作? – 2013-03-20 08:31:03

+0

我想你編輯了評論,我沒有看到更新。當請求爲「http:// domain.com /」時,它會轉到「http://domain.com/typo/index.php?id=106」,它不會修改瀏覽器地址欄中的請求URL。因此[NC,L]標誌。要**看到**重定向的URL,必須使用標誌'R'或'R = 301'。 – 2013-03-20 08:39:34