jef*_*nes 2 .htaccess mod-rewrite redirect http-status-code-301
所以我有一系列的重定向到一堆我想要重定向到他们的父目录的页面(例如/ faq/question1/ - >/faq /),但是它非常不灵活,因为它们是手动生成的.
如何RewriteRule为此设置RegEx-燃料?我无法弄明白,并且非常喜欢一些指导.这是我的整个.htaccess,以避免任何冲突(你可以看到RewriteRules我现在的个人):
AddDefaultCharset utf-8
AddHandler php5-script .php
DirectoryIndex index.php
ErrorDocument 403 /errors/forbidden.html
ErrorDocument 500 /errors/internalerror.html
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^halftoneproductions.com
RewriteRule (.*) http://www.halftoneproductions.com/$1 [R=301,L]
# FAQ redirects
RewriteRule ^faq/how-much-does-it-cost-to-make-an-albummix-a-songetc /faq/ [R=301,L]
RewriteRule ^faq/im-a-singersongwriter-with-no-band-members-would-you-be-able-to-do-a-full-production-of-my-songs-with-session-musicians /faq/ [R=301,L]
RewriteRule ^faq/do-you-do-postsound-for-film-at-all /faq/ [R=301,L]
RewriteRule ^faq/i-have-a-home-studio-and-just-need-to-record-___-is-that-cool /faq/ [R=301,L]
RewriteRule ^faq/are-you-a-publishing-company /faq/ [R=301,L]
RewriteRule ^faq/do-you-need-any-interns-or-runners /faq/ [R=301,L]
RewriteRule ^faq/can-i-bring-my-own-producerengineer-to-a-session /faq/ [R=301,L]
RewriteRule ^faq/what-types-of-music-do-you-work-on /faq/ [R=301,L]
RewriteRule ^faq/do-you-work-with-languages-other-than-english /faq/ [R=301,L]
RewriteRule ^faq/do-you-guys-make-beats /faq/ [R=301,L]
RewriteRule ^faq/i-have-an-old-tape-reelcasetteminidiscetc-and-would-love-to-transfer-it-to-some-other-form-can-you-help-out /faq/ [R=301,L]
RewriteRule ^faq/i-have-my-own-producerengineeretc-and-just-need-help-working-out-a-budget-for-my-project-and-booking-studio-time-can-you-help-out /faq/ [R=301,L]
# Recent Work redirects
RewriteRule ^recent-work/josh-and-neal /recent-work/ [R=301,L]
RewriteRule ^recent-work/midnights-son /recent-work/ [R=301,L]
RewriteRule ^recent-work/bearkat /recent-work/ [R=301,L]
RewriteRule ^recent-work/madi-diaz /recent-work/ [R=301,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Run Code Online (Sandbox Code Playgroud)
如果要重定向URL路径具有/faq/前缀的所有请求,可以使用以下规则:
RewriteRule ^faq/. /faq/ [R=301,L]
Run Code Online (Sandbox Code Playgroud)
单个.表示任意字符.因此,每个以URL路径开头的请求/faq/后跟至少一个字符的请求都会重定向到/faq/.
| 归档时间: |
|
| 查看次数: |
2470 次 |
| 最近记录: |