my old site was mydomain.com/index.php?route=product/product&product_id=<number>
When I add the rewrite rule, if I don't include the /index.php, the rewrite works, but if I include it, it doesn't work.
Is there a solution to this? All of my old urls on google have /index.php in them, so I need some way to handle this.
Any ideas?
Thanks
Solved! Go to Solution.
You can try RewriteRule in .htaccess:
https://linchpinseo.com/htaccess-rules/
example:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php/?$ / [L,R=301,NC]
I needed to turn this https://example.com/index.php?route=product/product&product_id=<id>
into this https://example.com/index.php?route=product/product&product_id=<id>
This was what worked in the end
RewriteEngine On RewriteBase "/" RewriteCond %{REQUEST_URI} ^/index\.php$ RewriteCond %{QUERY_STRING} (route.*) RewriteRule "(.*)index.php" $1%1? [R=301,L]
Just try below shared solutions, you can enable:
https://meetanshi.com/blog/remove-index-php-from-url-in-magento/
https://magento.stackexchange.com/questions/141736/remove-index-php-from-getbaseurl
Thanks, but that's already turned on.
My new site don't have /index.php in the urls, but the old one does. I'm trying to work around that for all of my cached google results
@web_master12 so are you looking to remove index.php from all url rewrites or looking from crawled google results?
I want that when someone clicks on a link in google that has an old url - including /index.php - it should route to my new site based on a url rewrite, and not just go to my new homepage
You can try RewriteRule in .htaccess:
https://linchpinseo.com/htaccess-rules/
example:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php/?$ / [L,R=301,NC]
I needed to turn this https://example.com/index.php?route=product/product&product_id=<id>
into this https://example.com/index.php?route=product/product&product_id=<id>
This was what worked in the end
RewriteEngine On RewriteBase "/" RewriteCond %{REQUEST_URI} ^/index\.php$ RewriteCond %{QUERY_STRING} (route.*) RewriteRule "(.*)index.php" $1%1? [R=301,L]