[英]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.