使用TYPO3中的.htaccess隐藏重定向/到子文件夹

Aha*_*ius 1 .htaccess rewrite typo3

我们正在设置TYPO3安装,如果用户调用example.com/,我们希望服务器重定向到/typo/index.php?id=106.

这应该在地址栏没有变化的情况下发生.应将服务器上的每个其他文件访问权限(例如example.com/test.png)重定向到example.com/typo/test.png).

这是根目录中的.htaccess文件.据我了解,它会将URL 中没有/拼写错误的所有内容重定向到子文件夹并附加参数:

RewriteCond %{REQUEST_URI} !^/typo/
RewriteRule ^(.*)$ typo/$1 [L]
Run Code Online (Sandbox Code Playgroud)

现在,这似乎已经工作了,当我打电话给example.com/index.php?id=106我没有得到404.不幸的是TYPO3似乎有些麻烦(或.htaccess配置不正确),因为我们收到一条消息"没有指定输入文件".

还缺少的是没有指定路径时的初始重定向.然后应该转到/typo/index.php?id=106.

Fel*_*a A 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]
Run Code Online (Sandbox Code Playgroud)

静默地图:

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]