REPOST:htaccess 错误及优化
有人可以帮助我优化和修复我的 .htaccess 文件吗?我真的不擅长正则表达式,而且我不是服务器人员,而且我正在构建的网站由于错误而无法访问。任何帮助将非常感激。
SetEnv _SRVR_ENV beta
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
## Paypal Callback Rules
RewriteCond %{QUERY_STRING} token=(\w+-\w+)&PayerID=(\w+)
RewriteRule ^some-seo-text-(\w+)-(\w+)\.html /index.php?c=$1&m=$2&token=%1&payerid=%2 [L]
RewriteCond %{QUERY_STRING} token=(\w+-\w+)
RewriteRule ^some-seo-text-(\w+)-(\w+)-(\w+)\.html /index.php?c=$1&m=$2&token=%3 [L]
RewriteCond %{QUERY_STRING} token=(\w+-\w+)
RewriteRule ^some-seo-text-(\w+)-(\w+)\.html /index.php?c=$1&m=$2&token=%1 [L]
RewriteCond %{QUERY_STRING} session=(.*)
RewriteRule ^some-seo-text-(\w+)-(\w+)\.html /index.php?c=$1&m=$2&session=%1 [L]
## Custom Rules
RewriteRule ^some-seo-text-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.html$ /index.php?c=$1&m=$2&v1=$4&v2=$6&v3=$8 [L]
RewriteRule ^some-seo-text-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.html$ /index.php?c=$1&m=$2&v1=$4&v2=$6 [L]
RewriteRule ^some-seo-text-(.*)-(.*)-(.*)-(.*)\.html$ /index.php?c=$1&m=$2&v1=$4 [L]
RewriteRule ^some-seo-text-(.*)-(.*)\.html$ /index.php?c=$1&m=$2 [L]
RewriteRule ^some-seo-text-(.*)-(.*)\.html$ /index.php?c=$1&m=$2 [L]
RewriteRule ^some-seo-text-(.*)\.html$ /index.php?c=$1 [L]
## Directory Cloaking
RewriteRule ^images/another-seo-text-(.*)$ /static/images/$1 [L]
RewriteRule ^deals/another-seo-text-(.*)$ /static/images/campaigns/$1 [L]
RewriteRule ^css/(.*)$ /static/stylesheets/$1 [L]
RewriteRule ^js/(.*)$ /static/javascripts/$1 [L]
RewriteRule ^captcha/(.*)$ /static/captcha/$1 [L]
Can anybody help me optimize and fix my .htaccess file? I'm really bad at regex and I'm not a server person and site I'm building is inaccessible because of the error. Any help would be very much appreciated.
SetEnv _SRVR_ENV beta
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
## Paypal Callback Rules
RewriteCond %{QUERY_STRING} token=(\w+-\w+)&PayerID=(\w+)
RewriteRule ^some-seo-text-(\w+)-(\w+)\.html /index.php?c=$1&m=$2&token=%1&payerid=%2 [L]
RewriteCond %{QUERY_STRING} token=(\w+-\w+)
RewriteRule ^some-seo-text-(\w+)-(\w+)-(\w+)\.html /index.php?c=$1&m=$2&token=%3 [L]
RewriteCond %{QUERY_STRING} token=(\w+-\w+)
RewriteRule ^some-seo-text-(\w+)-(\w+)\.html /index.php?c=$1&m=$2&token=%1 [L]
RewriteCond %{QUERY_STRING} session=(.*)
RewriteRule ^some-seo-text-(\w+)-(\w+)\.html /index.php?c=$1&m=$2&session=%1 [L]
## Custom Rules
RewriteRule ^some-seo-text-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.html$ /index.php?c=$1&m=$2&v1=$4&v2=$6&v3=$8 [L]
RewriteRule ^some-seo-text-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.html$ /index.php?c=$1&m=$2&v1=$4&v2=$6 [L]
RewriteRule ^some-seo-text-(.*)-(.*)-(.*)-(.*)\.html$ /index.php?c=$1&m=$2&v1=$4 [L]
RewriteRule ^some-seo-text-(.*)-(.*)\.html$ /index.php?c=$1&m=$2 [L]
RewriteRule ^some-seo-text-(.*)-(.*)\.html$ /index.php?c=$1&m=$2 [L]
RewriteRule ^some-seo-text-(.*)\.html$ /index.php?c=$1 [L]
## Directory Cloaking
RewriteRule ^images/another-seo-text-(.*)$ /static/images/$1 [L]
RewriteRule ^deals/another-seo-text-(.*)$ /static/images/campaigns/$1 [L]
RewriteRule ^css/(.*)$ /static/stylesheets/$1 [L]
RewriteRule ^js/(.*)$ /static/javascripts/$1 [L]
RewriteRule ^captcha/(.*)$ /static/captcha/$1 [L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请注意,
(.*)
很乐意匹配 URL 中的-
,这使得许多匹配变得不明确,并且可能非常缓慢。您的\w
匹配可能更有意义。您能否将您上次已知的正常工作
.htaccess
与此之间的diff(1)
粘贴起来?这将帮助您快速找到故障。Note that
(.*)
will happily match a-
in an URL, making many of these matches ambiguous, and perhaps very slow. Your\w
matches probably make more sense.Can you paste the
diff(1)
between your last known good working.htaccess
and this one? That would help you find the fault quickly.