mod_rewrite不会重定向到我的内部网址

时间:2013-11-19 09:20:01

标签: regex apache .htaccess mod-rewrite

我正在尝试为我的网上商店解决mod_rewrite规则。

网址为:localhost/myshop/category1/category2/myproduct.html

重定向网址应为:localhost/myshop/configurator/product/configure/id/1/s/myproduct/category1/5/

如果我尝试像这样的RewriteRule

RewriteRule ^myproduct\.html$ http://localhost/myshop/configurator/product/configure/id/1/s/myproduct/category1/5/

没有任何反应,重定向也不会出现。

我做错了什么?

我在.htaccess中的重写规则

RewriteBase /myshop/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
RewriteRule ^myproduct\.html$ http://localhost/myshop/configurator/product/configure/id/1/s/myproduct/category1/5/

我希望myproduct.html立即重定向到配置程序链接,所以我想实现一个RewriteRule

1 个答案:

答案 0 :(得分:2)

尝试重新订购您的规则:

RewriteEngine On

RewriteBase /myshop/

RewriteRule (^|/)myproduct\.html$ /myshop/configurator/product/configure/id/1/s/myproduct/category1/5/ [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]