Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 请参阅htaccess代码_.htaccess - Fatal编程技术网

.htaccess 请参阅htaccess代码

.htaccess 请参阅htaccess代码,.htaccess,.htaccess,我只是想知道是否有人能看一下我的htaccess代码,告诉我是否有明显不正确的地方。我对这东西了解不多。也不确定零件是否应以不同方式组织,或者是否有必要放置 “打开发动机 重写基/ 在那里不止一次? 无论如何,下面是代码: RewriteEngine on RewriteBase / RewriteRule ^(.+)\.shtml$ $1.html [R=301,L] redirect 301 /games.html http://www.slimekids.com/ga

我只是想知道是否有人能看一下我的htaccess代码,告诉我是否有明显不正确的地方。我对这东西了解不多。也不确定零件是否应以不同方式组织,或者是否有必要放置 “打开发动机 重写基/ 在那里不止一次? 无论如何,下面是代码:

RewriteEngine  on 
RewriteBase    / 

RewriteRule ^(.+)\.shtml$   $1.html [R=301,L] 

redirect 301 /games.html http://www.slimekids.com/games/
redirect 301 /trailers.html http://www.slimekids.com/book-trailers/
redirect 301 /authors.html http://www.slimekids.com/authors/
redirect 301 /reference.html http://www.slimekids.com/reference/
redirect 301 /reviews.html http://www.slimekids.com/book-reviews/
redirect 301 /searches.html http://www.slimekids.com/search-engines/

RewriteEngine on
RewriteBase /

#if the domain is not www.slimekids.com
RewriteCond %{HTTP_HOST} !^www\.slimekids\.com$ [NC]
#redirect to www.slimekids.com
RewriteRule ^(.*)$ http://www.slimekids.com/$1 [L,R=301]

#leave this rule in place, but after the one above to handle the home page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/ 
RewriteRule ^index\.html$ http://www.slimekids.com/ [R=301,L] 

ErrorDocument 404 /404page.html

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
重新编写引擎打开
重写基/
重写规则^(+)\.shtml$$1.html[R=301,L]
重定向301/games.htmlhttp://www.slimekids.com/games/
重定向301/trailes.htmlhttp://www.slimekids.com/book-trailers/
重定向301/authors.htmlhttp://www.slimekids.com/authors/
重定向301/reference.htmlhttp://www.slimekids.com/reference/
重定向301/reviews.htmlhttp://www.slimekids.com/book-reviews/
重定向301/searches.htmlhttp://www.slimekids.com/search-engines/
重新启动发动机
重写基/
#如果域不是www.slimekids.com
重写cond%{HTTP_HOST}^www\.slimekids\.com$[NC]
#重定向至www.slimekids.com
重写规则^(.*)$http://www.slimekids.com/$1[L,R=301]
#保留此规则,但在上面的规则之后处理主页
重写cond%{THE_REQUEST}^[A-Z]{3,9}\/index\.html\HTTP/
重写规则^index\.html$http://www.slimekids.com/ [R=301,L]
ErrorDocument 404/404page.html
##过期缓存##
过期于
过期按类型图像/jpg“访问1年
过期按类型图像/jpeg“访问1年”
ExpiresByType image/gif“访问1年”
过期按类型图像/png“访问1年”
ExpiresByType文本/css“访问1个月”
过期按类型应用程序/pdf“访问1个月”
ExpiresByType文本/x-javascript“访问1个月”
过期按类型应用程序/x-shockwave-flash“访问1个月”
过期按类型图像/x图标“访问1年”
ExpiresDefault“访问2天”
##过期缓存##
代码看起来不错

您认为不需要重复
上的
重写引擎和
重写库/
,这是正确的

我注意到exprires的未来相当遥远。例如,图像在一年后过期。可能是您的代码在发生更改时使用了某种缓存破坏

我可能会稍微更改从url中删除
index.html
部分的行,以便同时处理子文件夹(例如
/games/index.html
),而不仅仅是根文件夹(
/index.html


新的和改进的htaccess。希望现在一切看起来都很好。非常感谢

RewriteEngine on
RewriteBase /

RewriteRule ^(.+)\.shtml$   $1.html [R=301,L] 

redirect 301 /games.html http://www.slimekids.com/games/
redirect 301 /trailers.html http://www.slimekids.com/book-trailers/
redirect 301 /authors.html http://www.slimekids.com/authors/
redirect 301 /reference.html http://www.slimekids.com/reference/
redirect 301 /reviews.html http://www.slimekids.com/book-reviews/
redirect 301 /searches.html http://www.slimekids.com/search-engines/

#if the domain is not www.slimekids.com
RewriteCond %{HTTP_HOST} !^www\.slimekids\.com$ [NC]
#redirect to www.slimekids.com
RewriteRule ^(.*)$ http://www.slimekids.com/$1 [L,R=301]

#leave this rule in place, but after the one above to handle the home page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/ 
RewriteRule ^(.*)index\.html$ http://www.slimekids.com/$1 [R=301,L]

ErrorDocument 404 /404page.html

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 month"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##
重新编写引擎打开
重写基/
重写规则^(+)\.shtml$$1.html[R=301,L]
重定向301/games.htmlhttp://www.slimekids.com/games/
重定向301/trailes.htmlhttp://www.slimekids.com/book-trailers/
重定向301/authors.htmlhttp://www.slimekids.com/authors/
重定向301/reference.htmlhttp://www.slimekids.com/reference/
重定向301/reviews.htmlhttp://www.slimekids.com/book-reviews/
重定向301/searches.htmlhttp://www.slimekids.com/search-engines/
#如果域不是www.slimekids.com
重写COND%{HTTP_HOST}!^www.slimekids.com$[NC]
#重定向至www.slimekids.com
重写规则^(.*)$http://www.slimekids.com/$1[L,R=301]
#保留此规则,但在上面的规则之后处理主页
重写cond%{THE_REQUEST}^[A-Z]{3,9}\/index\.html\HTTP/
重写规则^(.*)索引\.html$http://www.slimekids.com/$1[R=301,L]
ErrorDocument 404/404page.html
##过期缓存##
过期于
ExpiresByType图像/jpg“访问1个月”
过期按类型图像/jpeg“访问1个月”
ExpiresByType image/gif“访问1个月”
ExpiresByType图像/png“访问1个月”
ExpiresByType文本/css“访问1个月”
过期按类型应用程序/pdf“访问1个月”
ExpiresByType文本/x-javascript“访问1个月”
过期按类型应用程序/x-shockwave-flash“访问1个月”
ExpiresByType图像/x图标“访问1个月”
ExpiresDefault“访问2天”
##过期缓存##

您收到了哪些错误?您想做什么?您需要更具体一些。我想我不是在寻找真正的特定错误,但我想知道其中是否有任何不必要的东西,比如“RewriteBase上的RewriteEngine/“或者,如果某件东西看起来不正常或需要放在其他地方。嘿,谢谢你的回复。那么,我取出哪一个“RewriteEngine on RewriteBase/”重要吗,还是放在哪里无关紧要?另外,我注意到有一个结尾的斜杠移得更远了。我也不确定这是否重要。关于过期,这是否意味着如果我更改jpg图像,一些用户可能会在一年内看不到更改?不知道你说的破坏缓存是什么意思,但听起来你是在建议缩短过期时间。我把这部分放在那里的原因是为了提高速度(当我做谷歌页面速度测试时,它建议这样做),但我认为将过期时间从一年改为一个月并不会在这方面产生太大的影响。我不清楚你关于修改删除index.html的行以同时处理子文件夹的意思是什么?为什么我需要解释像/games/index.html这样的结尾呢?只保留第一个。我喜欢把它们放在规则之前,但我相信这并不重要。在基础中,间距并不重要。在您的示例中,一年内没有更新图像的说法是正确的。改用一个月的时间或多或少会带来同样的速度提升。仅仅添加规则有点冒险,因为一些工具在不理解它的情况下这么说。如果谷歌加载带有url
/games/index.html
的页面,它将得到与
/games/
相同的页面(我猜)。搜索引擎将检测重复的内容,并将只索引其中一个URL。为了防止谷歌选择长的/丑的,只需将其重定向到短的/漂亮的。
RewriteEngine on
RewriteBase /

RewriteRule ^(.+)\.shtml$   $1.html [R=301,L] 

redirect 301 /games.html http://www.slimekids.com/games/
redirect 301 /trailers.html http://www.slimekids.com/book-trailers/
redirect 301 /authors.html http://www.slimekids.com/authors/
redirect 301 /reference.html http://www.slimekids.com/reference/
redirect 301 /reviews.html http://www.slimekids.com/book-reviews/
redirect 301 /searches.html http://www.slimekids.com/search-engines/

#if the domain is not www.slimekids.com
RewriteCond %{HTTP_HOST} !^www\.slimekids\.com$ [NC]
#redirect to www.slimekids.com
RewriteRule ^(.*)$ http://www.slimekids.com/$1 [L,R=301]

#leave this rule in place, but after the one above to handle the home page
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/ 
RewriteRule ^(.*)index\.html$ http://www.slimekids.com/$1 [R=301,L]

ErrorDocument 404 /404page.html

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 month"
ExpiresDefault "access 2 days"
</IfModule>
## EXPIRES CACHING ##