如何使用.htaccess文件将主页重定向到唯一的url


How to redirect just homepage to unique url with .htaccess file

我想将'packagingindustry.frainggroup.com'重定向到'frainggroup.com/blog',但在'packagiingindustry.flainggroup.com'中有几个链接,我想重定向到'flainggroup.com',而不带尾部的slug'blog'

我如何唯一地将主页url重定向到包括"博客",而如果任何其他包含任何slugs的永久链接(例如"packagingindustry.frainggroup.com/blog-title")重定向到frainggroup.com(例如"frainggroup.com/blog title")

以下是我正在使用的两个重定向语句:

# Redirect /index.php 'www.fraingroup.com/blog/'
# Redirect 301 / 'fraingroup.com/'

尝试:

RedirectMatch 301 ^/(index'.php)?$ http://fraingroup.com/blog

Redirect指令还将在比赛后重定向所有内容,因此/几乎重定向整个网站。但是,使用regex和RedirectMatch,您可以限制为仅完全匹配。