使用 .htaccess 的 301 重定向重定向 404
Redirecting 404s using 301 redirects with .htaccess
我正在编辑的 .htaccess 文件包含以下用于重定向的代码 http://www.example.com to http://example.com:
AddHandler fcgid54-script .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
无需从头编写新的 .htaccess 文件,我希望重定向返回 404 的其他几个页面。我尝试了以下但没有用:
AddHandler fcgid54-script .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
301 Redirect /blank/blah/page/ http://example.org/blank/blah/
# END WordPress
我也尝试了很多其他的迭代,但到目前为止没有任何效果。
不要将 mod_rewrite
规则与 mod_alias
规则混合使用,并在内部 WP 规则之前保留 301:
AddHandler fcgid54-script .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^blank/blah/page/?$ http://example.org/blank/blah/ [L,NC,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
试试这个它会起作用:
ErrorDocument 404 http://www.example.com/abc.html
通过在 htaccess
文件中添加此行,返回 404 的页面将转发到指定的 url。比如http://www.example.com/abc.html
我正在编辑的 .htaccess 文件包含以下用于重定向的代码 http://www.example.com to http://example.com:
AddHandler fcgid54-script .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
无需从头编写新的 .htaccess 文件,我希望重定向返回 404 的其他几个页面。我尝试了以下但没有用:
AddHandler fcgid54-script .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
301 Redirect /blank/blah/page/ http://example.org/blank/blah/
# END WordPress
我也尝试了很多其他的迭代,但到目前为止没有任何效果。
不要将 mod_rewrite
规则与 mod_alias
规则混合使用,并在内部 WP 规则之前保留 301:
AddHandler fcgid54-script .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^blank/blah/page/?$ http://example.org/blank/blah/ [L,NC,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
试试这个它会起作用:
ErrorDocument 404 http://www.example.com/abc.html
通过在 htaccess
文件中添加此行,返回 404 的页面将转发到指定的 url。比如http://www.example.com/abc.html