Your WordPress website was working very well on your local machine and once you upload it to cPanel on shared hosting, it didn’t work as expected.
The first problem you may face is the website doesn’t open the home page or any page with the error “This site can’t be reached”. the second problem is the redirecting to localhost or 8080 port. Let’s see how to solve these problems.
Fixing .htaccess file for WorldPress.
One of the most common problems is .htaccess, we need to configure the .htaccess for index.php file, the file that starts WordPress. Add the follow code in “public_html/.htaccess”
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Configure WordPress Options.
To stop WordPress from auto redirecting you need to configure “siteurl” and “home” url. Open the “wp_options” table in your database and search for “siteurl” and “home” in option_name column then change their values in option_value column to your domain url “https://example.com”.
Add the following code to the “wp-config.php” file
define('WP_HOME', 'https://example.com');
define('WP_SITEURL', 'https://example.com');
I hope this article code help.