如何在亚马逊服务器上配置来自www的重定向



我们通过Amazon Bitnami在服务器上放置了一个网站(Wordpress)。我们试图设置从www.site.com到site.com的重定向(去掉"www")。然而,它现在从任何www子页面重定向到主页www.site.com(而不是正确的子页面)。(从www.site.com/page到site.com,而不是到site.com/page)如何设置有www子页面的重定向到没有www的网站的同一页面。?

我将代码添加到Apache httpd.conf文件中。LoadModule rewrite_module modules/mod_rewrite.so

AllowOverride controls what directives may be placed in .htaccess files.It can be "All", "None", or any combination of the keywords:AllowOverride FileInfo AuthConfig Limit

`AllowOverride All` 

还编辑了文件:.htaccess、httpd-app.conf、httpd-vhosts.conf

这可能只是一个htaccess问题。尝试在您的htaccess中使用此代码,将示例替换为您的站点名称

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteRule ^index.php$ - [L]

最新更新