我正在尝试为我的网上商店解决mod_rewrite规则。
网址为:localhost/myshop/category1/category2/myproduct.html
重排URL应为: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立即重定向到configurator链接,所以我想实现RewriteRule
最佳答案
尝试重新排序规则:
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]