简体   繁体   中英

Hidden redirect of / to subfolder using .htaccess in TYPO3

We're setting up a TYPO3 installation, and if the user calls example.com/ we'd like the server to redirect to /typo/index.php?id=106 .

This should happen without a change in the address bar. Every other file access on the server (for example example.com/test.png) should be redirected to example.com/typo/test.png).

This is the .htaccess file in the root directory. As I understand, it will redirect everything which doesn't have /typo in the URL to the subfolder and attach the parameters:

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

Now, this already seems to work, when I call example.com/index.php?id=106 I'm not getting a 404. Unfortunately TYPO3 seems to have some trouble (or the .htaccess configuration isn't correct), because we get a message saying "No input file specified".

What's also missing is the initial redirect when no path is specified. It should then go to /typo/index.php?id=106.

You may try this in one .htaccess file in root directory:

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]

Maps silently:

http://domain.com/ to

http://domain.com/typo/index.php?id=106

and

http://domain.com/anything

http://domain.com/typo/anything

For permanent redirection, replace [NC,L] with [R=301,NC,L]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM