[英]remove folder from url using .htaccess
I know there are plenty of other questions similar to this one, i tried followinf some of those, but with no luck. 我知道还有很多与此问题类似的问题,我尝试了其中的一些问题,但是没有运气。
I have a website called test.com and i need, when someone seraches for test.com to show the content in test.com/home, without having home in the uerl. 我有一个名为test.com的网站,我需要一个有人为test.com进行搜索以在test.com/home中显示内容,而又不会在家中居住。
My htaccess file at the moment looks like this: 此刻我的htaccess文件如下所示:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule /(.*) home/$1 [L]
RewriteRule /home/(.*) /$1 [L,R=302]
RewriteOptions inherit
RewriteCond %{HTTP_HOST} ^test\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.test\.com$
but when i type test.com it shows a list of folders, not the content inside home. 但是当我键入test.com时,它显示的是文件夹列表,而不是家庭内部的内容。
What am i doing wrong? 我究竟做错了什么?
thanks 谢谢
You can simplify your rules to this in root .htaccess 您可以在根.htaccess中简化规则。
RewriteEngine on
RewriteBase /
RewriteRule ^$ home/ [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?!home/).+)$ home/$1 [L,NC]
Make sure to clear your browser cache before testing this. 在测试之前,请确保清除浏览器缓存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.