My problem is that my domain example.com points to the root directory of my server (normal behaviour) but the website is located in the subdirectory sub .
With the following .htaccess I achieved that my domain is redirected to the subdirectory sub without changig the URL!
RewriteEngine On
RewriteRule !^/sub /sub%{REQUEST_URI} [L,NC]
The frontpage is displayed correctly and the url is still example.com (that's correct). But when I click on a link to visit a sub page (Example link: example.com/my-company), the page redirects me to example.com/sub (so back to the frontpage - I don't want that). After the redirect these links still don't work.
How can I achieve that these links work without the subfolder in the address bar? To summarize:
I redirect my domain example.com to a sub folder called sub and don't display the folder sub in the address bar. I want, that the whole page works without the sub folder in the address bar.
In the background we use typo3. Here is the .htaccess of the sub folder:
Options None
Options +FollowSymlinks
RewriteEngine On
RewriteBase /sub
RewriteRule ^(typo3|t3lib|tslib|fileadmin|typo3conf|typo3temp|uploads|showpic\.php|favicon\.ico)/ - [L]
RewriteRule ^typo3$ - [L]
RewriteRule ^typo3/.*$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php
# to avoid double content
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
So, how do I achieve this?
This is because RewriteRule will issue a redirect by default. You need to tell it not to perform a redirect. You can do this using the PassThrough floaf [PT]
The following should then work:
RewriteRule !^/sub/(.*)$ /sub/$1 [L,NC,PT]
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.