【问题标题】:Wordpress non-www to www redirects all urls to home instead that urlWordpress 非 www 到 www 将所有 url 重定向到 home 而不是那个 url
【发布时间】:2017-07-24 08:27:10
【问题描述】:

我所有的非 www url 都重定向到我的主页

这是我的 htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

【问题讨论】:

  • 我不明白你的问题?你能说得更具体点吗?

标签: wordpress .htaccess no-www


【解决方案1】:

如果您只想强制所有内容都使用 www,那么这应该可以解决问题。

# Needed before any rewriting
RewriteEngine On

# Redirect HTTP without www to HTTP with www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Redirect HTTPS without www to HTTPS with www
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

## 301 Redirects can go after this

【讨论】:

    【解决方案2】:

    不要忘记在wp_options 表或设置中设置您的域。

    另外,将此行放入您的.htaccess

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^opcito.com [NC]
    RewriteRule ^(.*)$ http://www.opcito.com/$1 [L,R=301]
    
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    

    希望对你有帮助:)

    【讨论】:

      猜你喜欢
      • 2011-06-24
      • 2019-03-09
      • 2011-11-05
      • 2013-12-20
      • 2015-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多