【发布时间】:2026-02-10 06:10:01
【问题描述】:
我的 .htaccess 文件中有一些重写代码。我已经将一个静态 HTML 网站移到 wordpress 中,需要以下内容才能工作:
- 将http://domain.com.au/ 重定向到http://www.domain.com.au/
- 重定向(旧的静态主页)index.html 到http://www.domain.com.au/
我无法工作,我已经尝试了所有建议的方法。 domain.com.au 到http://www.domain.com.au 适用于除主页之外的所有页面,例如http://domain.com.au/ourteam 重定向到 http://www.domain.com.au/ourteam
但它不会重定向到根目录(主页)。
我还收到 index.html 重定向的页面未找到错误。
我的 .htaccess 文件是:
Options +FollowSymlinks
RewriteEngine on
### re-direct index.html to root
RewriteCond %{THE_REQUEST} ^.*\/index\.html
RewriteRule ^(.*)index\.html$ /$1 [R=301,L]
### non www to www
RewriteCond %{HTTP_HOST} ^domain\.com\.au$ [NC]
RewriteRule ^(.*)$ http://www.domain.com.au/$1 [R=301,L]
redirect 301 /team.html http://www.domain.com.au/our-team/
redirect 301 /contact.html http://www.domain.com.au/contact-us/
任何人都可以帮助 - 我正在为此撕毁我的头发!
【问题讨论】:
-
我也有类似的问题。我也尝试使用 Cpanel Redirects,然后使用一些 Wordpress 插件,然后将此代码添加到 .htaccess 但似乎没有任何效果。但是它在其他网站上也可以使用相同的代码。