cancel
Showing results for 
Search instead for 
Did you mean: 

Having trouble with URL rewrites from old website

SOLVED

Having trouble with URL rewrites from old website

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 

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Having trouble with URL rewrites from old website

@web_master12 

 

You can try RewriteRule in .htaccess:

https://linchpinseo.com/htaccess-rules/

https://craftcms.stackexchange.com/questions/11311/removing-index-php-from-url-even-after-htaccess-u...

example:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^index\.php/?$ / [L,R=301,NC]

 

 

Manish Mittal
https://www.manishmittal.com/

View solution in original post

Re: Having trouble with URL rewrites from old website

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]

View solution in original post

6 REPLIES 6

Re: Having trouble with URL rewrites from old website

@web_master12 

 

Just try below shared solutions, you can enable:

  1. Log in to Admin panel
  2. Navigate to Stores > Configuration > General > Web
  3. Expand the Search Engine Optimization section
  4. Set “yes” to Use Web Server Rewrites option.

https://meetanshi.com/blog/remove-index-php-from-url-in-magento/

https://magento.stackexchange.com/questions/141736/remove-index-php-from-getbaseurl

Manish Mittal
https://www.manishmittal.com/

Re: Having trouble with URL rewrites from old website

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

Re: Having trouble with URL rewrites from old website

@web_master12  so are you looking to remove index.php from all url rewrites or looking from crawled google results?

Manish Mittal
https://www.manishmittal.com/

Re: Having trouble with URL rewrites from old website

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

Re: Having trouble with URL rewrites from old website

@web_master12 

 

You can try RewriteRule in .htaccess:

https://linchpinseo.com/htaccess-rules/

https://craftcms.stackexchange.com/questions/11311/removing-index-php-from-url-even-after-htaccess-u...

example:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^index\.php/?$ / [L,R=301,NC]

 

 

Manish Mittal
https://www.manishmittal.com/

Re: Having trouble with URL rewrites from old website

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]