dongmeba4877
2011-05-14 01:20
浏览 43
已采纳

htaccess代码导致500错误

I'm following a book tutorial (Effortless Ecommerce by Larry Ullman) to build an ecommerce site. When I add the following code to my htaccess file to rewrite URLs and also enforce SSL, it returns a 500 error when I try to load my site.

Does anyone have any ideas what the problem/solution might be?

RewriteEngine on
# For sales:
RewriteRule ^shop/sales/?$ sales.php
# For the primary categories:
RewriteRule ^shop/([A-Za-z\ ] )/?$ shop.php?type=$1
# For specific products:
RewriteRule ^browse/([A-Za-z\ \-] )/([A-Za-z\ \-] )/([0-9] )$ browse.php?type=$1&category=$2&id=$3
# For HTTPS pages:
RewriteCond %{HTTPS} off
RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L]



RewriteCond %{HTTPS} off RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L]

图片转代码服务由CSDN问答提供 功能建议

我正在按照书籍教程(Larry Ullman的Effortless Ecommerce)来构建电子商务网站。 当我将以下代码添加到我的htaccess文件中以重写URL并强制执行SSL时,当我尝试加载我的网站时,它会返回500错误。

有没有人有任何想法是什么问题 /解决方案可能是?

  RewriteEngine on 
#对于销售:
RewriteRule ^ shop / sales /?$ sales.php 
#对于主要类别:
RewriteRule ^  shop /([A-Za-z \])/?$ shop.php?type = $ 1 
#对于特定产品:
RewriteRule ^ browse /([A-Za-z \ \  - ])/([A  -Za-z \ \  - ])/([0-9])$ browse.php?type = $ 1& category = $ 2& id = $ 3 
#对于HTTPS页面:
RewriteCond%{HTTPS} off \  nRewriteRule ^(checkout \ .php | billing \ .php | final \ .php | admin /(.*))$ https://%{HTTP_HOST} / $ 1 [R = 301,L] 
 
 
 
  nRewriteCond%{HTTPS}关闭RewriteRule ^(checkout \ .php | billing \ .php | final \ .php | admin /(.*))$ https://%{HTTP_HOST} / $ 1 [R = 301,L] \  n   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • duanjiao5261 2011-05-14 01:56
    已采纳

    There are some minor syntax errors in your .htaccess. I have fixed them, pls try this:

    Options +FollowSymlinks -MultiViews
    RewriteEngine on
    
    # For sales:
    RewriteRule ^shop/sales/?$ sales.php [L,NC]
    # For the primary categories:
    RewriteRule ^shop/([^/]*)/?$ shop.php?type=$1 [L,NC]
    # For specific products:
    RewriteRule ^browse/([^/]*)/([^/]*)/([0-9])/?$ browse.php?type=$1&category=$2&id=$3 [L,NC]
    # For HTTPS pages:
    RewriteCond %{HTTPS} off
    RewriteRule ^(checkout\.php|billing\.php|final\.php|admin/(.*))$ https://%{HTTP_HOST}/$1 [R=301,L,NC]
    
    评论
    解决 无用
    打赏 举报
查看更多回答(3条)

相关推荐 更多相似问题