我正在尝试将http://www.example.me
重定向到http://example.me
,但由于某种原因,它无效。有人可以通过告诉.htaccess
文件中的错误来帮助我吗?
<IfModule mod_rewrite.c>
RewriteEngine On
SetEnvIfNoCase User-Agent "^libwww-perl*" block_bad_bots
Deny from env=block_bad_bots
RewriteCond %{HTTP_USER_AGENT} libwww [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)=http [NC]
RewriteRule ^(.*)$ – [F,L]
RewriteCond %{HTTP_HOST} ^www\.example\.me$
RewriteRule ^/?$ "http\:\/\/example\.me\/“ [R=301,L]
# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0
# Set up caching on media files for 1 month
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
ExpiresDefault A2419200
Header append Cache-Control "public"
</FilesMatch>
# Set up 2 Hour caching on commonly updated files
<FilesMatch "\.(xml|txt|html|js|css)$">
ExpiresDefault A7200
Header append Cache-Control "proxy-revalidate"
</FilesMatch>
# Force no caching for dynamic files
<FilesMatch "\.(php|cgi|pl|htm)$">
ExpiresActive On
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>
</IfModule>
答案 0 :(得分:0)
尝试此操作,也不要在规则中使用引号
RewriteCond %{HTTP_HOST} ^www\.example\.me$
RewriteRule ^ http:\\example.me [R=301,L]
答案 1 :(得分:0)
这是引号的问题。以下是正确的.htaccess
此行中的错误与最后一句
有关RewriteRule ^/?$ "http\:\/\/example\.me\/" [R=301,L]
您可以在下方查看完整正确的.htaccess文件
<IfModule mod_rewrite.c>
RewriteEngine On
SetEnvIfNoCase User-Agent "^libwww-perl*" block_bad_bots
Deny from env=block_bad_bots
RewriteCond %{HTTP_USER_AGENT} libwww [NC,OR]
RewriteCond %{QUERY_STRING} ^(.*)=http [NC]
RewriteRule ^(.*)$ – [F,L]
RewriteCond %{HTTP_HOST} ^www\.example\.me$
RewriteRule ^/?$ "http\:\/\/example\.me\/" [R=301,L]
# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0
# Set up caching on media files for 1 month
<FilesMatch "\.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
ExpiresDefault A2419200
Header append Cache-Control "public"
</FilesMatch>
# Set up 2 Hour caching on commonly updated files
<FilesMatch "\.(xml|txt|html|js|css)$">
ExpiresDefault A7200
Header append Cache-Control "proxy-revalidate"
</FilesMatch>
# Force no caching for dynamic files
<FilesMatch "\.(php|cgi|pl|htm)$">
ExpiresActive On
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>
</IfModule>