apache 1.3 中的 Mod_ReWrite 脚本在 2.2 中不起作用
我一直在使用以下脚本来获取友好的 url,它在 apache 1.3 中工作正常。我们刚刚升级到 apache 2.2.17,它似乎不再工作了。
有什么需要调整才能在 2.2 中工作吗?
mysite.com/products?BRAND=ADIDAS&VENDORCODE=581 (ORIGINAL URL)
mysite.com/products/ADIDAS/581 (FRIENDLY URL)
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*/)?products/([^/]+)/([0-9]+)/?$ $1/products?BRAND=$2&VENDORCODE=$3 [PT,L]
RewriteRule ^(.*/)?products/([^/]+)/([^/]+)/([0-9]+)/?$ $1/products?BRAND=$2&VENDORCODE=$3&offset=$4 [PT,L]
RewriteRule ^(.*/)?DeptItems/([^/]+)/([0-9]+)/?$ $1/DeptItems?BRAND=$2&catCode=$3 [PT,L]
RewriteRule ^(.*/)?DeptItems/([^/]+)/([^/]+)/([0-9]+)/?$ $1/DeptItems?BRAND=$2&catCode=$3&offset=$4 [PT,L]
RewriteRule ^(.*/)?itemdetail/([^/]+)/([^/]+)/?$ $1/itemdetail?BRAND=$2&desc1=$3 [PT,L]
I had been using the following script for friendly urls and it is working fin in apache 1.3. We just upgraded to apache 2.2.17 and it doesnt seem to be working anymore.
Is there something that needs to be tweaked to work in 2.2?
mysite.com/products?BRAND=ADIDAS&VENDORCODE=581 (ORIGINAL URL)
mysite.com/products/ADIDAS/581 (FRIENDLY URL)
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*/)?products/([^/]+)/([0-9]+)/?$ $1/products?BRAND=$2&VENDORCODE=$3 [PT,L]
RewriteRule ^(.*/)?products/([^/]+)/([^/]+)/([0-9]+)/?$ $1/products?BRAND=$2&VENDORCODE=$3&offset=$4 [PT,L]
RewriteRule ^(.*/)?DeptItems/([^/]+)/([0-9]+)/?$ $1/DeptItems?BRAND=$2&catCode=$3 [PT,L]
RewriteRule ^(.*/)?DeptItems/([^/]+)/([^/]+)/([0-9]+)/?$ $1/DeptItems?BRAND=$2&catCode=$3&offset=$4 [PT,L]
RewriteRule ^(.*/)?itemdetail/([^/]+)/([^/]+)/?$ $1/itemdetail?BRAND=$2&desc1=$3 [PT,L]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
RewriteEngine On
需要独占一行。它不是Options
的参数。RewriteEngine On
needs to be on its own line. Its not an argument toOptions
.对于 Apache2.2
在您的 httpd.conf 文件中,您必须设置 AllowOverride All
For Apache2.2
In your httpd.conf file you must set AllowOverride All