I changed my Wordpress folder name in htdocs as localhost/ecom/ and now when I try to access localhost/ecom/wp-admin/ it shows page not found
Add this to
wp-config.php before line
/* That's all, stop editing! Happy blogging. */
and check if it works.
define( 'WP_HOME', 'http://localhost/ecom' ); define( 'WP_SITEURL', 'http://localhost/ecom' );
I think that it is always better to change the URLs in wp-options table, rather changing the wp-config.php entries.
See this entry in the Codex https://codex.wordpress.org/Changing_The_Site_URL where it says
This is not necessarily the best fix, it's just hardcoding the values into the site itself. You won't be able to edit them on the General settings page anymore when using this method.
So, although changing the values in wp-config.php will work (and is often stated as an 'answer'), I think that the more correct way is to set the proper URLs in the wp-options table.