要让.htaccess
允许fa
图标显示,我做了一些更改。
以前www.mywebsite.com
fa
图标不可见。我在.htaccess
添加了几行,然后就开始工作了。
<IfModule mod_headers.c>
<FilesMatch "\.(eot|font.css|otf|ttc|ttf|woff)$">
Header set Access-Control-Allow-Origin "http://www.mywebsite.com"
</FilesMatch>
</IfModule>
<IfModule mod_mime.c>
# Web fonts
AddType application/font-woff woff
AddType application/vnd.ms-fontobject eot
# Browsers usually ignore the font MIME types and sniff the content,
# however, Chrome shows a warning if other MIME types are used for the
# following fonts.
AddType application/x-font-ttf ttc ttf
AddType font/opentype otf
# Make SVGZ fonts work on iPad:
# https://twitter.com/FontSquirrel/status/14855840545
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
</IfModule>
现在,mywebsite.com
(没有www)无效。所以我添加了
Header set Access-Control-Allow-Origin "http://mywebsite.com"
喜欢这个
标题集设置Access-Control-Allow-Origin&#34; http://www.mywebsite.com&#34; 标题集设置Access-Control-Allow-Origin&#34; http://mywebsite.com&#34;
mywebsite.com
开始奏效了。现在www.mywebsite.com
已停止工作。
我在我的网站上使用wordpress
。我错过了什么?
修改 我尝试根据各种论坛的建议添加3行,但我最终得到500内部错误。
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
我缺少什么,是否需要将此代码放在某个<ifModule>
块中?
答案 0 :(得分:1)
您可能没有启用rewrite module。首先,将您的htaccess文件更新为:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(eot|font.css|otf|ttc|ttf|woff)$">
Header set Access-Control-Allow-Origin "http://www.mywebsite.com"
</FilesMatch>
</IfModule>
<IfModule mod_mime.c>
# Web fonts
AddType application/font-woff woff
AddType application/vnd.ms-fontobject eot
# Browsers usually ignore the font MIME types and sniff the content,
# however, Chrome shows a warning if other MIME types are used for the
# following fonts.
AddType application/x-font-ttf ttc ttf
AddType font/opentype otf
# Make SVGZ fonts work on iPad:
# https://twitter.com/FontSquirrel/status/14855840545
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
</IfModule>
然后,确保启用了重写模块:
# Check if it's enabled:
apachectl -M | grep rewrite
# You might need sudo here:
a2enmod rewrite
# On platforms that a2enmod is not available, you need
# to open up your httpd.conf file and uncomment the line
# that looks like this:
LoadModule rewrite_module libexec/mod_rewrite.so