0

I have a WordPress site, https://dogx.hu, and a separate Laravel eCommerce site. My primary objective is to redirect from the "/shop" URL of the WordPress site to the Laravel site. In other words, when users navigate to dogx.hu/shop, I want them to see the eCommerce site.

Could someone assist me with this? I appreciate your help! I've attempted redirection, but it hasn't been sufficient. I'm encountering errors.

1
  • Another common practice is to load a store through a subdomain - store.dogx.hu - shop.dogx.hu Then you could really skip the redirect all together and just link directly to it.
    – Bazdin
    Commented Apr 13 at 20:34

1 Answer 1

0

You can add this to your child theme's functions.php' file:

If you have the WooCommerce plugin installed and want to redirect the default store address to another address:

function custom_redirect_shop_page_atakanau() {
  if ( is_shop() ) {
    wp_redirect( 'https://domain.tld/custom-url' );
    exit;
  }
}
add_action( 'template_redirect', 'custom_redirect_shop_page_atakanau' );

This code redirects to the custom url when the store page is visited.

UPDATED:

The following code redirects requests to the /old-slug URL to the /new-slug URL:

function custom_redirect_url_slug_atakanau() {
  if ($_SERVER['REQUEST_URI'] == '/old-slug') {
    wp_redirect( '/new-slug', 301 );
    exit;
  }
}
add_action('init', 'custom_redirect_url_slug_atakanau');

Except those; If you're looking to run WordPress and Laravel together on the same server without URL redirection, check out this: laravel and wordpress on the same domain(laravel in subfolder)

2
  • Thanks a lot for you comment. Also is there a way or possible to load laravel commerce site the same url ? without redirect. So like dogx.hu/shop will load the laravel site with wordpress page. i mean dogx.hu - load the blog site and dogx.hu/shop will load the laravel site Need symlink or someting similar?
    – devdani7
    Commented Apr 12 at 18:30
  • @devdani7 I explained redirection because your issue focuses on URL redirection. I have updated my answer now.
    – Atakan Au
    Commented Apr 13 at 14:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.