2014-03-13 65 views
1

如何将目录重定向到站点的根目录?前提是:重定向目录(但不是子目录)到另一个目录

  • 该网站的根目录实际上并不是域的根目录。例如:它应该重定向到“www.example.com/website”,而不是“www.example.com”

  • 不重定向子文件夹。例如:它应该将“www.example.com/website/portfolio”重定向到“www.example.com/website”,但它不应该重定向“www.example.com/website/portfolio/project-name”。

这是一个WordPress站点,它已经与下列规则工作:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /website/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /website/index.php [L] 
</IfModule> 
# END WordPress 

提前感谢!

回答

1

你可以这样做:

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /website/ 

RewriteRule ^portfolio/?$ /website/ [L,R] 

RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /website/index.php [L] 
</IfModule> 
相关问题