I have a website and I want to add a code line in the .htaccess file in order to redirect automaticaly the pages to another site.
Redirect
/index.php/component/virtuemart/XXXXX.html
https://www.trazeras.gr/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=XXXXX
The XXXXX ais a number which could have 1-5 digits The above number should be taken from the initial site url and to be used at the destination site url
I tried the following code but it doesnt work
# Redirect Query String
<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} ^/virtuemart/([0-9]+) [NC]
RewriteRule ^(.*)$ https://www.trazeras.gr/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=%1? [R=301,L]
</IfModule>
any thoughts?
The URL doesn't have a query string, so you shouldn't redirect using it:
# Redirect Query String
<IfModule mod_rewrite.c>
RewriteRule ^/virtuemart/([0-9]+) https://www.trazeras.gr/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=$1 [NC,R=301,L]
</IfModule>
最后,这对我有用:
RewriteRule ^(.*)virtuemart/([0-9]+).html$ https://www.trazeras.gr/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=$2 [R=301,L] [R=301,L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.