2012-01-19 90 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