重定向到页面

时间:2012-01-19 01:06:02

标签: .htaccess redirect

我目前有这个:

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]

1 个答案:

答案 0 :(得分: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]