REPOST:htaccess 错误及优化

发布于 2024-10-27 05:22:35 字数 2139 浏览 2 评论 0原文

有人可以帮助我优化和修复我的 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

栀子花开つ 2024-11-03 05:22:36

请注意,(.*) 很乐意匹配 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文