HTAccess无法正常工作

时间:2013-12-29 15:12:45

标签: html .htaccess

我已经按照几个在线指南将“londonosophy.com”重定向到“www.london ...”版本,但它似乎没有重定向。关注重复内容,有人可以建议如何改进我所拥有的htaccess文件吗?

RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^londonosophy\.com$
RewriteRule ^(.*) http://www.londonosophy.com/$1 [R=301]

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://([ -a-z0-9]  \.)?londonosophy\.com [NC]
RewriteRule \.(gif|jpe?g|png)$ - [F,NC,L]

#cache html and htm files for one day
<FilesMatch ".(html|htm)$">
Header set Cache-Control "max-age=43200"
</FilesMatch>

#cache css, javascript and text files for one week
<FilesMatch ".(js|css|txt)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>

#cache flash and images for one month
<FilesMatch ".(flv|swf|ico|gif|jpg|jpeg|png)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>

#disable cache for script files
<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
Header unset Cache-Control
</FilesMatch>

1 个答案:

答案 0 :(得分:0)

如果您想重定向到.htaccess文件中的"londonosophy.com" to the "www.london..."使用贝娄代码

# This allows you to redirect your entire website to any other domain
Redirect 301 / http://www.london...

正如你评论所说“我只是想在我的每个网址前添加”www“作为重定向”。所以使用下面的代码将解决问题

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]