Skip to main content
Share Your Experience: Take the 2024 Developer Survey
7 votes
Accepted

How can I programmatically perform a 301 redirect in Magento 2

In your class declare the variable /** * @var \Magento\Framework\App\ResponseInterface */ protected $_response; In constructor initialize the object public function __construct ( ...
Manoj Kumar's user avatar
  • 1,348
6 votes

Magento 2 with Varnish sometimes does not redirect HTTP to HTTPS

The issue was the Pound was only listening to 443 (https) and all HTTP was going straight to Varnish. Magento was supposed to be redirecting but sometimes Varnish would just send the HTTP version. ...
YWSW's user avatar
  • 336
6 votes
Accepted

Redirecting HTTP to HTTPS?

I fixed it by adding RewriteCond %{HTTPS} !=on RewriteRule ^(.*)$ https://mydomain.co.uk/$1 [L,R=301] To my .htaccess and setting Auto-Redirect to base url to No Hope this helps someone
AspiringProgrammer's user avatar
6 votes

Magento 2: Bulk 301 rewrite imports

If you can load your CSV file content then This is the way to import Bulk URL Rewrite: Add below Code into script than run it. // MAGENTO START include('../../../app/bootstrap.php'); use ...
Ronak Chauhan's user avatar
4 votes

Magento 2.2.5: Admin login page redirect loop 301/302 after installing SSL and enabling HTTPS

Try the following query: SELECT * FROM `core_config_data` WHERE path = 'web/secure/use_in_adminhtml' ; if path web/secure/use_in_adminhtml has value of null Update the value to 1 using the ...
AbdulKarim's user avatar
3 votes
Accepted

302 redirect issues. Page header shows 302 for all pages

I fixed it - in my case a GEO Location extension was responsible for the issue. Anyway - to check in general I recommend to take a look in .htaccess index.php search for keywords like "...
Xavin's user avatar
  • 405
2 votes

Marketpress to Magento: 301 redirect using htaccess

Assuming category-name varies, then I don't see any way you can do this solely from 301 rewrites in a .htaccess file. You may need to redirect the old URLs to a custom-coded script that will then ...
Aric Watson's user avatar
2 votes

Magento HTACCESS query 301 redirect all but admin

This version will allow you to still see the admin styles. RewriteEngine on RewriteBase / RewriteCond %{REQUEST_URI} !^/admin RewriteCond %{REQUEST_URI} !^admin RewriteCond %{REQUEST_URI} !^/skin ...
Gillian's user avatar
  • 21
2 votes

how can i change all urls of old website

add below in your old domian .htaccess file RewriteEngine on RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
Prashant Valanda's user avatar
2 votes

Magento 2: Bulk 301 rewrite imports

I had to do this by exporting the url_rewrite database table then added my custom redirects and imported via phpMyadmin and works fine.
Steve B's user avatar
  • 681
2 votes
Accepted

Bulk import and redirect 301 (over 14K url) in core_url_rewrite or on server

htaccess is good Idea .But it is too tuff write code for 14k urls in a htaccess file, Better idea to rewrite using magento code and that case ,you can use 3rd party extensions like https://www....
Amit Bera's user avatar
  • 77.5k
2 votes
Accepted

How to do redirect in Magento 2

If you want to redirect from root script, you need to use this try { require_once __DIR__ . '/app/bootstrap.php'; } catch (\Exception $e) { echo 'Autoload error: ' . $e->getMessage(); ...
WISAM HAKIM's user avatar
  • 2,135
2 votes

Best practices of 404 product page redirection in magento

As of my knowledge, I have been facing similar issues. You can alternately use below steps. First step is, convert or redirect the 404 pages into catalog search results, So that your visitors get a ...
Krishna ijjada's user avatar
2 votes
Accepted

Multiple URL Rewrites for the same product is SEO issue?

Multiple URLs explanation: Thanks to Kalvin Klien, as he mentioned in the comment. The Sitemap URLs are crawled by Google. By default the category path is not added in the product URL as the ...
Rajkumar Vellaiswamy's user avatar
2 votes
Accepted

Magento 2.2.5: Admin login page redirect loop 301/302 after installing SSL and enabling HTTPS

Solution #1: Resolve incorrect database entries Ensure that all values are properly set within the core_config_data database table. Search for unsecure_base_url and ensure that the value of the table ...
Muckee's user avatar
  • 699
1 vote
Accepted

Best way to handle store switch redirects in Magento 2

Yes. You can create redirection rules (store-wise) and redirect to the correct URL for the targeted store. However, this is only feasible for limited products. For a larger product set or a bunch of ...
Magento TridhyaTech's user avatar
1 vote
Accepted

SEO URL rewrites content goes missing

Your destination page 'waverly' doesn't exist. Even if it did this isn't going the work the way you're envisioning it. When you forward the request by 301 to 'waverly' your 'find-a-builder' controller ...
Michigan Websites's user avatar
1 vote

ERR_TOO_MANY_REDIRECTS magento admin

Problem Solved ! I have tried many solutions, but none of them work. Finally, I figured out a successful solution. Step one, Check your proxy server configuration, In my scenario I used nginx as proxy ...
Harsha Liyadipita's user avatar
1 vote
Accepted

Redirect 301 removing parameters in URL by .htaccess

You can try to use two rewrite conditions - one for the QUERY_STRING and one for the REQUEST_URI and let the matching pattern be .* in the rewrite rule. RewriteCond %{QUERY_STRING} ^PageSpeed=...
HelgeB's user avatar
  • 4,521
1 vote
Accepted

Rewrite Rules to revert URL structure?

By leveraging web server capabilities on working with .htaccess rules and having RewriteRule module enabled, you could write a rule as the following: RewriteRule ^/?([^/]+(?:/[^/]+)?)/(\d+)(?:\.\d+)?\...
revo's user avatar
  • 360
1 vote
Accepted

Http to https 301 redirect

Ok, I found out what the problem was about. Instead of configuring the unsecure URL with the https one, I configured the url with the http one and then modified the .htaccess to handle the redirect ...
Niko Zarzani's user avatar
1 vote

Migration from Squarespace to Magento Addressing 301 Redirects on Mass

AFAIK, you can try: STORES > Configuration > CATALOG > Catalog > Search Engine Optimization > Category URL Suffix
Khoa TruongDinh's user avatar
1 vote

Magento 2: Mass 301 Redirects for 404 Pages

This is how I would approach this. From the admin panel click on the Marketing module. Under SEO & Search click on the URL rewrite. From there create a custom URL rewrite for the links that you ...
Rebel's user avatar
  • 305
1 vote
Accepted

M2: How to redirect contact form page to CMS page

Create a custom url rewrite in your admin. Target path: custom-cms-url (without any slahes /) Request path: contact Make sure you have a cron job setup for reindexing and that the url rewrite was ...
Lez's user avatar
  • 2,917
1 vote
Accepted

Magento: Delete products and 301 redirect to relevant it's parent category

In ./app/code/local/INPUTANAME/RewriteAfterDelete/etc/config.xml put <?xml version="1.0" encoding="UTF-8"?> <config> <modules> <INPUTANAME_RewriteAfterDelete> ...
meet's user avatar
  • 373
1 vote

How to redirect users to specific page when they go to any pages?

You can check you redirect condition before every action using observer, you have to use controller_action_predispatch event for this, check below steps create app/code/Namespace/Module/etc/frontend/...
Piyush's user avatar
  • 5,904
1 vote

How to redirect users to specific page when they go to any pages?

Take the following steps to write a redirect rule for your Magento 2 website: Log in to your Magento 2 administrative panel. In the main menu, click Marketing In the Marketing menu, click URL ...
Vishwas Bhatnagar's user avatar
1 vote

Magento 2: 301 Redirects

There are a few ways: In the .htaccess or VirtualHost configuration of Apache or nginx A Router observer in Magento that maps a regex of particular patterns to rewrite to the new Magento location ...
philwinkle's user avatar
  • 35.8k
1 vote

Marketpress to Magento: 301 redirect using htaccess

As @Aric Watson states: you cannot do this with plain .htaccess, because the category-name-slug will not be predictable from .htaccess. But... assuming you're only interested in creating 301's to the ...
Giel Berkers's user avatar
  • 12.3k

Only top scored, non community-wiki answers of a minimum length are eligible