[英]Website homepage to show subdirectory content via htaccess
I have a Wordpress website with root located at http://www.example.com/web 我有一个带有root的Wordpress网站,位于http://www.example.com/web
Via htaccess, when I visit that address I would like to see what's on http://www.example.com/web/about-me with the browser still displaying http://www.example.com/web . 通过htaccess,当我访问该地址时,我希望看到http://www.example.com/web/about-me上的内容,浏览器仍显示http://www.example.com/web 。
Is it possible to achieve this via .htaccess? 是否有可能通过.htaccess实现这一目标? What I have right now is
我现在拥有的是
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /web/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php [L]
</IfModule>
I tried adding at the bottom 我尝试在底部添加
RedirectMatch ^/$ /about-me/
Without any success. 没有任何成功。
So essentially you have a website which is hosted on a sub-directory of your domain, and you want to rewrite the homepage URL to your about-me page, but without the user seeing the URL change. 所以基本上你有一个托管在你的域的子目录上的网站,并且你想要将主页URL重写到你的about-me页面,但是没有用户看到URL的变化。 Your main issue is trying to use a Redirect which will change the displayed URL.
您的主要问题是尝试使用重定向,这将更改显示的URL。
This should do it 这应该做到这一点
RewriteBase /web # Dropped the / suffix otherwise the rewrites get //
## RewriteRule ^index\.php$ - [L] - # Removed because the Conditions below should be doing this?
RewriteRule ^$ /about-me [L] # Redirect homepage
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L] # dropped the /web prefix as that is managed by the RewriteBase
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.