我正在手动将一个网站迁移到另一个托管服务。所有内容(包括域名)都应保持不变。在此托管服务的根目录中有一个旧网站需要保留,因此我将新网站安装在一个子目录中。我为该网站创建了一个子目录,并在根目录的.htaccess中包含以下内容:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.org$
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subfolder/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.org$
RewriteRule ^(/)?$ subfolder/index.php [L]
</IfModule>
这是正确的重定向主页,但每隔一页显示与旧的网站视图,并给出404错误。我假设有一个问题,在我的.htaccess,但我不知道如何定位它。
编辑:在子目录中有一个.htaccess文件,因为它是从另一个环境复制过来的完整wordpress安装。以下是该文件的内容:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
# Redirs Base Redirect:
Redirect 301 /redirs https://redirs.io/containers/?co=client-organization&con=example.org&host=WP-Engine&gsheet=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2F19Hw1ApeEuzlW5P0e2A7aZ6lJBWCN9Kpkvtvg8LFokik%2Fedit%23gid%3D0&gfile301=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2Fe%2F2PACX-1vRs5snE204cb7OZB-xFep5Ju9rccjKaNX-jP9Nb0yZHGlXQ-4pPh63-K8EP7YErCQwbFgYJSf52zlBP%2Fpub%3Fgid%3D0%26single%3Dtrue%26output%3Dcsv&gfile302=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2Fe%2F2PACX-1vRs5snE204cb7OZB-xFep5Ju9rccjKaNX-jP9Nb0yZHGlXQ-4pPh63-K8EP7YErCQwbFgYJSf52zlBP%2Fpub%3Fgid%3D1333061259%26single%3Dtrue%26output%3Dcsv&gfileDomRules=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2Fe%2F2PACX-1vRs5snE204cb7OZB-xFep5Ju9rccjKaNX-jP9Nb0yZHGlXQ-4pPh63-K8EP7YErCQwbFgYJSf52zlBP%2Fpub%3Fgid%3D1293752576%26single%3Dtrue%26output%3Dcsv&gfileDoms=https%3A%2F%2Fdocs.google.com%2Fspreadsheets%2Fd%2Fe%2F2PACX-1vRs5snE204cb7OZB-xFep5Ju9rccjKaNX-jP9Nb0yZHGlXQ-4pPh63-K8EP7YErCQwbFgYJSf52zlBP%2Fpub%3Fgid%3D547864294%26single%3Dtrue%26output%3Dcsv
# Redirects with sources which do NOT contain a query string:
RedirectMatch 301 ^/parents-of-rsym/?$ https://example.org/youth/parents-of-river/
RedirectMatch 301 ^/index.php/mens-page/?$ https://example.org/mens-ministry/
RedirectMatch 301 ^/index.php/about/what-to-expect/?$ https://example.org/what-to-expect/
RedirectMatch 301 ^/index.php/about/staff-pr/?$ https://example.org/staff/
RedirectMatch 301 ^/index.php/about/statement-of-faith/?$ https://example.org/we-believe/
RedirectMatch 301 ^/index.php/about/contact-link/?$ https://example.org/contact/
RedirectMatch 301 ^/index.php/youth-page/?$ https://example.org/youth-group-ministry/
RedirectMatch 301 ^/index.php/womens-page/womens-ministry-blog/?$ https://example.org/womens-ministry-blog/
RedirectMatch 301 ^/index.php/resources/calendar2/?$ https://example.org/calendar/
RedirectMatch 301 ^/index.php/womens-page/?$ https://example.org/womens-ministry/
RedirectMatch 301 ^/index.php/96-recipes/?$ https://example.org/womens-ministry/
RedirectMatch 301 ^/?$ https://example.org/youth-group-ministry/
RedirectMatch 301 ^/index.php/programs/youth-page-2/youth-program-info-page/?$ https://example.org/youth-group-ministry/
RedirectMatch 301 ^/index.php/video/?$ /https://arlington.online.church/?fbclid=IwAR0IjoHt20yVnYZv-lbIKlgq1o-kLr1EbbfShSba3A6hAgMuzPMbZBlCCqs
RedirectMatch 301 ^/index.php/special-services/apologetics-forum-of-snohomish-county-afsc/?$ https://www.apologeticsforum.org
RedirectMatch 301 ^/index.php/programs/children-s-programs/vbs-form-signup-2/?$ https://example.org/childrens-ministry/
RedirectMatch 301 ^/index.php/programs/children-s-programs/how-can-children-sit-through-church/?$ https://example.org/how-can-children-sit-through-church/
RedirectMatch 301 ^/index.php/programs/children-s-programs/?$ https://example.org/childrens-ministry/
RedirectMatch 301 ^/index.php/programs/music-ministry-2/philosophy/?$ https://example.org/worship/
RedirectMatch 301 ^/index.php/programs/music-ministry-2/song-suggestions/?$ https://example.org/music-ministry/
RedirectMatch 301 ^/index.php/programs/music-ministry-2/info-page/?$ https://example.org/music-ministry/
RedirectMatch 301 ^/index.php/programs/music-ministry-2/girls-choir-info-link/?$ https://example.org/music-ministry/4-this-time-girls-choir/
RedirectMatch 301 ^/index.php/programs/music-ministry-2/?$ https://example.org/music-ministry/
RedirectMatch 301 ^/index.php/programs/youth-page-2/?$ https://example.org/youth-group-ministry/
RedirectMatch 301 ^/index.php/programs/college-info-page-2/?$ https://example.org/young-adults/
RedirectMatch 301 ^/index.php/programs/womens-page-2/womens-ministry-pics/?$ https://example.org/womens-ministry/
RedirectMatch 301 ^/index.php/programs/womens-page-2/womens-ministry-blog/?$ https://example.org/womens-ministry/
RedirectMatch 301 ^/index.php/programs/womens-page-2/?$ https://example.org/womens-ministry/
RedirectMatch 301 ^/index.php/programs/mens-page-2/podcasts/iron-sharpens-iron/?$ https://example.org/music-ministry/
RedirectMatch 301 ^/index.php/programs/mens-page-2/podcasts/?$ https://example.org/music-ministry/
RedirectMatch 301 ^/index.php/programs/mens-page-2/men-min-pics-link/?$ https://example.org/music-ministry/
RedirectMatch 301 ^/index.php/programs/mens-page-2/current-mens-link/?$ https://example.org/music-ministry/
RedirectMatch 301 ^/index.php/programs/mens-page-2/?$ https://example.org/music-ministry/
RedirectMatch 301 ^/index.php/programs/seniors-page-2/?$ https://example.org/senior-ministry/
RedirectMatch 301 ^/index.php/programs/?$ https://example.org/#ministries-church
RedirectMatch 301 ^/index.php/resources/altar-flower-gifts/?$ https://example.org
RedirectMatch 301 ^/index.php/resources/news-page/past-event-link/?$ https://example.org/calendar/
RedirectMatch 301 ^/index.php/resources/news-page/?$ https://example.org/calendar/
RedirectMatch 301 ^/index.php/resources/web-links/?$ https://example.org/calendar/
RedirectMatch 301 ^/index.php/resources/visitor-survey/?$ https://example.org
RedirectMatch 301 ^/index.php/resources/song-suggestions/?$ https://example.org/music-ministry/
RedirectMatch 301 ^/index.php/resources/sermons-page/2016/?$ https://example.org/media-library/
RedirectMatch 301 ^/index.php/resources/sermons-page/2015/?$ https://example.org/media-library/
RedirectMatch 301 ^/index.php/resources/sermons-page/2014/?$ https://example.org/media-library/
RedirectMatch 301 ^/index.php/resources/sermons-page/2013/?$ https://example.org/media-library/
RedirectMatch 301 ^/index.php/resources/sermons-page/2012/?$ https://example.org/media-library/
RedirectMatch 301 ^/index.php/resources/sermons-page/2011/?$ https://example.org/media-library/
RedirectMatch 301 ^/index.php/resources/sermons-page/2010/?$ https://example.org/media-library/
RedirectMatch 301 ^/index.php/resources/sermons-page/2009/?$ https://example.org/media-library/
RedirectMatch 301 ^/index.php/resources/sermons-page/2008/?$ https://example.org/media-library/
RedirectMatch 301 ^/index.php/resources/sermons-page/?$ https://example.org/media-library/
RedirectMatch 301 ^/index.php/resources/prayer-requests/?$ https://example.org/how-can-we-help/?ineedparam=Prayer
RedirectMatch 301 ^/index.php/resources/subscribe-to-our-mailing-list/?$ https://example.org
RedirectMatch 301 ^/index.php/resources/calendar2/calendar2-2/?$ https://example.org/calendar/
RedirectMatch 301 ^/index.php/resources/calendar2/calendar2/?$ https://example.org/calendar/
RedirectMatch 301 ^/index.php/resources/?$ https://example.org
RedirectMatch 301 ^/index.php/womens-page/womens-ministry-pics/?$ https://example.org/womens-ministry/
RedirectMatch 301 ^/index.php/womens-page/?$ https://example.org/womens-ministry/
RedirectMatch 301 ^/index.php/college-info-page/?$ https://example.org/young-adults/
RedirectMatch 301 ^/index.php/children-s-programs/how-can-children-sit-through-church/?$ https://example.org/bringing-children-to-church/
RedirectMatch 301 ^/index.php/children-s-programs/nursery/?$ https://example.org/childrens-ministry/nursery/
RedirectMatch 301 ^/index.php/children-s-programs/bible-day-camp/?$ https://example.org/childrens-ministry/
RedirectMatch 301 ^/index.php/children-s-programs/kids-club/?$ https://example.org/childrens-ministry/kids-club/
RedirectMatch 301 ^/index.php/children-s-programs/?$ https://example.org/childrens-ministry/
RedirectMatch 301 ^/index.php/about/staff-pr/staff/?$ https://example.org/staff/
RedirectMatch 301 ^/index.php/about/directions-page/?$ https://example.org/about-us/
RedirectMatch 301 ^/index.php/about/service-times/?$ https://example.org/about-us/
RedirectMatch 301 ^/index.php/about/?$ https://example.org/about-us/
RedirectMatch 301 ^/index.php/mens-page/podcasts/iron-sharpens-iron/?$ https://example.org/mens-ministry/
RedirectMatch 301 ^/index.php/mens-page/podcasts/?$ https://example.org/mens-ministry/
RedirectMatch 301 ^/index.php/mens-page/men-min-pics-link/?$ https://example.org/mens-ministry/
RedirectMatch 301 ^/index.php/seniors-page/?$ https://example.org/senior-ministry/
RedirectMatch 301 ^/index.php/music-ministry/philosophy/?$ https://example.org/worship/
RedirectMatch 301 ^/index.php/music-ministry/song-suggestions/?$ https://example.org/worship/
RedirectMatch 301 ^/index.php/music-ministry/girls-choir-info-link/?$ https://example.org/music-ministry/4-this-time-girls-choir/
RedirectMatch 301 ^/index.php/music-ministry/music-ministry/?$ https://example.org/music-ministry/
RedirectMatch 301 ^/index.php/music-ministry/?$ https://example.org/music-ministry/
RedirectMatch 301 ^/index.php/missions/past-mission-teams/?$ https://example.org/missionaries/
RedirectMatch 301 ^/index.php/missions/missions/missionaries/?$ https://example.org/missionaries/
RedirectMatch 301 ^/index.php/missions/missions/?$ https://example.org/missionaries/
RedirectMatch 301 ^/index.php/missions/?$ https://example.org/missionaries/
RedirectMatch 301 ^/index.php/youth-page/youth-program-info-page/?$ https://example.org/youth-group-ministry/
RedirectMatch 301 ^/index.php/?$ https://example.org
# Redirects with sources which contain a QUERY STRING:
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
1条答案
按热度按时间mznpcxlj1#
除非在子文件夹中有一个额外的
.htaccess
文件,否则这个RewriteRule
也应该将请求直接重写为subfolder/index.php
(与上一个规则相同)。例如:由于不需要反向引用,我还将
RewriteRule
模式简化为一个点(因此它匹配除根以外的所有内容-根由下一个规则处理)。您还缺少
L
标志。此操作成功后,不应再处理其他规则。更新日期:
编辑:子目录中有一个.htaccess文件
您可以将根
.htaccess
档案还原为原始的状态,但您必须在该规则中包含L
旗标,并移除斜扛前缀。例如:RewriteRule
* 模式 * 不需要起始锚点和结束锚点(即^
和$
)。但是,您需要更改
/subfolder/.htaccess
文件中的规则:1.完全移除
RewriteBase
指示词。请注意,这个指示词目前在档案中出现了两次(在顶端和最后的WP程式码区块中)。两个执行严修都必须移除。1.删除WordPress代码块最后一个规则中 substitution 字符串的斜杠前缀。换句话说,更改如下:
对此:
然而,一个潜在的问题,这是作为前面的评论警告... WordPress试图维护这一部分,所以你需要防止WordPress覆盖这些变化!