.htaccess 停止。要继续执行的访问规则
我已经在一个域名上与它的.htaccess规则斗争了很长一段时间。我找到了重定向所有不存在的文件和文件夹所需的规则,并在将其在.htaccess中的位置更改为top后使其正常工作,因此.htaccess现在看起来如下所示:.htaccess 停止。要继续执行的访问规则,.htaccess,mod-rewrite,redirect,.htaccess,Mod Rewrite,Redirect,我已经在一个域名上与它的.htaccess规则斗争了很长一段时间。我找到了重定向所有不存在的文件和文件夹所需的规则,并在将其在.htaccess中的位置更改为top后使其正常工作,因此.htaccess现在看起来如下所示: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRul
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ / [R=301,L]
</IfModule>
#Rewrite for non www
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/? [R=301,L]
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} acer|alcatel|amoi|android|asus|avantgo|benq|blackberry|blazer|boxee|bravia|cdm-|ce-html|compal|(core|gom|m|vlcmedia|windows-media)player|dlna|docomo|dreambox|elaine|ericsson|fennec|flycast|foobar2000|google\ wireless\ transcoder|googlebot-mobile|googletv|gt-|hbbtv|hiptop|htc|huawei|iemobile|im-|ipad|ipaq|iphone|ipod|iris|itunes|kindle|large|lg(-|\/|_|1|2|3|4|5|6|7|8|9|e|http)|lenovo|levis|maemo|midp|miro|mmp|mot-|mobile|motorola|msn.*tv|mtv|nettv|nexus|nintendo|nokia|opera\ (mobi|mini)|palm|panasonic|pantech|pg-|philips|pixi\/|playstation|plex|plucker|pocket|portalmmm|pre\/|psp|quicktime|qtek|rim|sagem|samsung|sanyo|sch-|screen|sec-sgh|sendo|sfr|sgh-|sharp|sie-|smart(hub|phone|.?tv)|sonyericsson|sph-|sprint|spv|swisscom|symbian|t-mobile|tablet|toshiba|touch|treo|upnp|up.browser|vertu|videoweb|vk-|vodafone|volksbox|wafa|wap|webos|webtv|wii|windows\ (ce|phone)|wml|wonu|xbmc|xbox|xda|xiino|zte|zune [NC]
RewriteRule ^(.*)$ http://www.domain.tld/m/ [L,R=302]
## 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 text/html "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 1 month"
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_deflate.c>
<filesMatch "\.(js|css|html|php|jpg|jpeg)$">
SetOutputFilter DEFLATE
</filesMatch>
</IfModule>
http://www.domain.tld/ <-- Mainsite
http://www.domain.tld/keywordX/1/ <-- Index folder for keyword X
http://www.domain.tld/keywordY/1/ <-- Index folder for keyword Y
http://www.domain.tld/keywordZ/1/ <-- Index folder for keyword Z
通过这段代码,我能够将所有不正确的文件夹请求重定向回root
现在缺少的是针对错误文件的重定向(重定向的主要部分是什么)。。。123_itemname.html、456_itemname.html等文件
有没有办法扩展我现在使用的htaccess代码,或者我需要一种全新的方法
编辑:我对这个问题做了很多编辑,因为我迫不及待地让其他人找出问题所在。出于某种原因,我的完整问题现在似乎已经过时了。。。。我把htaccess文件弄乱了。。。当我刚刚检查域时,它的文件大小为0。。。。将我在这里发布的内容再次复制到其中,最终得到了另一个完整的结果。。。而不是404错误,页面将不存在。。。它现在显示根目录的内容。。但保持它的弦状或。。。。有些事情似乎在困扰着我……出于某种原因,我的完整问题现在似乎有些过时了。。。。我把htaccess文件弄乱了。。。当我刚刚检查域时,它的文件大小为0。。。。将我在这里发布的内容再次复制到其中,最终得到了另一个完整的结果。。。而不是404错误,页面将不存在。。。它现在显示根目录的内容。。但保持它的弦状或。。。。我好像有点不对劲。。。。。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(keywordX|keywordY|keywordZ)($|/) - [L]
RewriteRule ^(.*)$ / [R=301,L]
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/(images)/ [NC]
RewriteCond %{REQUEST_URI} !\.(xml|txt|css)$
RewriteRule ^.+$ / [R=302,NC,L]