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

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]
  • 写回答

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条)

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?