htaccess Apache RewriteRule .asp to .php


htaccess Apache RewriteRule .asp to .php

我正在尝试使用htaccess中的RewriteRule来永久重定向此:

http://www.example.com/store/scripts/prodView.asp?idproduct=240

http://www.example.com/index.php?route=product/product&路径=59&product_id=50

我试过:

选项+FollowSymlinks

上的重写引擎

重写代码%{QUERY_STRING}^idproduct=240$[NC]

重写规则^store/scripts/prodView.asp$index.php''?route=产品;路径59;product_id=50?[L,NC,R=301]

.htaccess在根中

有人能告诉我哪里出了问题吗?感谢

尝试使用:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^idproduct=240$ [NC]
RewriteRule ^store/scripts/prodView'.asp$ index.php?route=product/product'&path=59'&product_id=50 [L,NC,R=301]

重写规则url 中没有'?

我在Croises的帮助下解决了这个问题,尽管我不知道问题的全部原因。

在我最初的问题中,为了简洁、相关和清晰,我省略了一些位于我正在编写的代码上方的RewriteRule代码。此代码由购物车软件提供。

RewriteRule代码的整体如下:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*'.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
#my code start
RewriteCond %{QUERY_STRING} ^idproduct=240$ [NC]
RewriteRule ^store/scripts/prodView'.asp$ index.php?route=product/product'&path=59'&product_id=50 [L,NC,R=301]
#my code end

下面的Croises问题让我思考"为什么我的代码被忽略了?"。因此,我把我的代码放在购物车的RewriteRule代码之上,现在它可以工作了,尽管我不明白为什么其他代码会干扰我的代码。

现在有效的代码是:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
#my code start
RewriteCond %{QUERY_STRING} ^idproduct=240$ [NC]
RewriteRule ^store/scripts/prodView'.asp$ index.php?route=product/product'&path=59'&product_id=50 [L,NC,R=301]
#my code end
#original code
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*'.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
#original code

因此,我想我已经回答了我的问题,但得到了克罗伊斯的帮助。很抱歉在最初的问题

中遗漏了一些重要信息