- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我想将我的网站宣传为 mydomain.com。对我来说,它看起来比 www.mydomain.com 好。用重定向修剪这个 www.
部分是一种常见的做法吗?有人会去 www.mydomain.com/books
,我会把他重定向到 mydomain.com/books
。这个想法背后有什么潜在的陷阱吗?
另一个原因是使第三方回调 URL 变得简单。现在,我需要将 mydomain.com/oauth/google
和 www.mydomain.com/oauth/google
声明为我的重定向 URL,因为 Google 认为它们不同。这不是什么大问题,但需要额外考虑。
如果修剪 www.
是安全的,如何实现?我在 Apache 上使用 PHP。我当前的 .htaccess 看起来像这样:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
最佳答案
您应该在 www.example.com 或 example.com 上进行规范化,您的选择主要取决于您的偏好。关于哪个是正确的或应该使用哪个,存在不同的意见。
no-www.org提倡使用 www 子域是多余的,因为使用 http 协议(protocol)意味着网络。
By default, all popular Web browsers assume the HTTP protocol. In doing so, the software prepends the 'http://' onto the requested URL and automatically connect to the HTTP server on port 80. Why then do many servers require their websites to communicate through the www subdomain? Mail servers do not require you to send emails to recipient@mail.domain.com. Likewise, web servers should allow access to their pages though the main domain unless a particular subdomain is required.
yes-www.org另一方面提倡使用 www 子域,因为它可以让您的网站更加灵活。通过使用 www 子域,您可以通过在 dns 记录中使用 CNAME 来更轻松地使用诸如 CDN/云托管之类的东西。
When using a provider such as Heroku or Akamai to host your web site, the provider wants to be able to update DNS records in case it needs to redirect traffic from a failing server to a healthy server. This is set up using DNS CNAME records, and the naked domain cannot have a CNAME record.
当您在另一个域上托管静态 Assets 时,它还可以帮助防止不必要的 cookie 流量。
One common web site optimization is to serve static content from a subdomain, such as static.example.com. If you are using www, then this is no problem; your site’s cookies won’t be sent to the static subdomain (unless you explicitly set them up to do so).
您需要将所有流量重定向到您最终使用的版本。对于 apache,这可以使用 mod_rewrite 完成,如其他答案所示:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
如果您能够编辑主要的 apache 配置,另一种选择是设置两个虚拟主机,其中一个只是重定向到另一个。我为我的网站这样做,效果很好。
<VirtualHost *:80>
ServerName example.com
Redirect permanent / http://www.example.com/
</VirtualHost>
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /var/www
#The rest of your configuration
</VirtualHost>
关于php - 重定向跳过 www 是常见的做法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38729554/
如果您想分享更多信息,可以在这里找到整个资源 指针: https://github.com/sergiotapia/DreamInCode.Net 基本上,我的API将为其他开发人员提供
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 5 年前。 Improve this qu
我不是 SCM 工具的经验丰富的用户,尽管我确信它们的用处,当然。 我在以前的工作中使用了一些不起眼的商业工具,在当前的工作中使用了 Perforce,并在我的小型个人项目中使用了 TortoiseS
所以我想知道一些我应该避免在 javascript 中做的事情以获得良好的 SEO 排名。在我的下一个站点中,我将广泛使用 jquery 和 javascript,但不想牺牲 SEO。那么您认为我应该
基本上,我想知道什么是避免 future CSS 代码出现问题和混淆的最佳方法... 像这样命名 CSS 属性: div#content ul#navigation div.float-left (真
我是一名优秀的程序员,十分优秀!