2
因此,我有一系列重定向,希望重定向到他们的父目录(例如/ faq/question1/- >/faq /),但它非常不灵活,因为它们是手动生成的。如何使用mod_rewrite将子页面/目录重定向到父目录?
我该如何为此设置RegEx燃料RewriteRule
?我一直无法弄清楚,并会非常喜欢一些指导。这里是我的整个的.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
Gumbo,非常感谢你。我对此感到头痛,这让我发疯。我有一些东西接近于此,但它导致/ faq /本身的重定向循环。总是那些简单的东西... – jeffbyrnes 2010-04-16 17:42:54
为了找到这个解决方案而搜索得很远,没有其他的工作,谢谢!拯救生命:) – ByteMyPixel 2017-08-22 19:52:48