2012-01-19 109 views
0

网页目前,我有这样的:重定向到

redirect 301 ^/about/ /about.html 
redirect 301 ^/about/skills/ /skills.html 
redirect 301 ^/about/experience/ /experience.html 
redirect 301 ^/about/projects/ /projects.html 

我想重定向到/about/about.html/about/skills//skills.html

但上面redirect■不要工作,仍然要/about/

应该是我的redirect 301是?

注意这些的低于我的重定向:

# Protect application and system files from being viewed 
RewriteRule ^(system) - [F,L] 

# Allow any files or directories that exist to be displayed directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 


RewriteRule .* index.php/$0 [PT,L] 

回答

0

Redirect不允许你指定一个正则表达式。

做到这一点的一种方法是在现有规则之前将以下规则添加到.htaccess中。

RewriteRule ^about/$ /about.html [NC,R=301,L] 
RewriteRule ^about/skills/$ /skills.html [NC,R=301,L] 
RewriteRule ^about/experience/$ /experience.html [NC,R=301,L] 
RewriteRule ^about/projects/$ /projects.html [NC,R=301,L] 
+0

还有一个问题。 '/ about'没有被重定向。只有'/ about /'是。我会做些什么来包含'/ about'? – 2012-01-19 02:01:00

+0

我做的一个快速修复是'^(/ about/| about)$ /about.html [NC,R = 301,L]'但还有更好的方法吗? – 2012-01-19 02:04:33

+0

@ThorpeObazee使尾部斜线可选使用'?'即'^ about /?$ /about.html [NC,R = 301,L]' – 2012-01-19 02:42:36