1

我们正在设置 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。

4

1 回答 1

8

您可以在根目录中的一个 .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]

于 2013-03-20T08:15:24.800 回答