【问题标题】:Redirect all the pages to the single page using htaccess?使用 htaccess 将所有页面重定向到单个页面?
【发布时间】:2021-03-05 21:32:00
【问题描述】:

我正在使用 WordPress,我必须将所有页面重定向到 index.html 页面(我在根文件夹中创建临时)。

我尝试了下面的代码,但它只重定向主页。

Redirect 301 "index.html" "https://www.examle.com"

我试过了

RewriteRule ^(.*)$ https://www.examle.com/$1 [R=permanent,L] //getting error(The page isn’t redirecting properly)

我试过下面的代码

RewriteCond %{REQUEST_URI} !/index.html$ 
RewriteCond %{REMOTE_HOST} !^00.00.00.00   //my ip
RewriteRule $ /index.html [R=302,L]

任何其他将所有页面重定向到 index.html 的解决方案?我的网站上有 50 多个页面。我想重定向 index.html 上的所有内容

【问题讨论】:

  • 你能分享你当前.htaccess文件的内容吗?
  • @ozgur,我一一尝试了上面的所有,RewriteEngine On 在顶部

标签: wordpress .htaccess redirect mod-rewrite url-rewriting


【解决方案1】:

您可以用它覆盖现有的.htaccess 文件内容。请注意,此代码假定您的 wordpress 安装在 root directory 上。

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule . /index.html [R=302,L]

【讨论】:

  • 我尝试了您的代码,但问题是,如果我访问 examle.com/about,那么我将获得关于我们的页面。一般,应该重定向到index.html页面
  • 是的,我希望所有页面都重定向到 index.html 页面。
猜你喜欢
  • 2016-07-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-06-30
  • 2018-02-04
  • 2014-08-10
  • 2014-03-15
相关资源
最近更新 更多