当前位置: 动力学知识库 > 问答 > 编程问答 >

.htaccess - Redirect to pages

问题描述:

I currently have this:

redirect 301 ^/about/ /about.html

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

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

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

I want to redirect /about/ to about.html, /about/skills/ to /skills.html

But the above redirects don't work and are still going to /about/

What should be my redirect 301 be?

Note that these ones are below my redirects:

# 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]

网友答案:

Redirect does not allow you to specify a regex.

One way to do this is to add the rules below to your .htaccess, ahead of your existing rules.

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]
分享给朋友:
您可能感兴趣的文章:
随机阅读: