Issues while configuring the site URL and its redirection problems

Aaditya Jujagar

New member
Registered
Joined
Feb 29, 2024
Messages
1
Points
1
Need help from htaccess experts and Wordpress gurus.

My problem:

My website is abc.com

Wordpress is installed in /wordpress folder

1) If anyone requests abc.com in the browser, it automatically forwards to 'abc.com/wordpress'. This is done using htaccess file and the website homepage opens normally. I would like to remove '/wordpress' from the address bar. Meaning the browser should display 'abc.com' only instead of 'abc.com/wordpress'.
How can we acheive this?

2) Also, for any internal links in the webiste, I would like to remove '/wordpress' in the browser path. So, if anyone requests 'Services' webpage which can be accessed from homepage, they should see:
'abc.com/services' instead of 'abc.com/wordpress/services' in the address bar.

At the moment, if someone requests 'Services' webpage from homepage, the browser directs to 'abc.com/wordpress/Services' but comes with an error:

This page isn’t working
abc.com redirected you too many times.
Try deleting your cookies.
ERR_TOO_MANY_REDIRECTS

However, after navigating to the address bar and removing 'wordpress' text from this i.e. just typing 'abc.com/Services', this comes back with the normal 'Services' page displayed normally.

Could someone please help me to resolve the above?


My current htaccess file looks like this:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?abc.com$
RewriteCond %{REQUEST_URI} !^/wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wordpress/$1
RewriteCond %{HTTP_HOST} ^(www.)?abc.com$
RewriteRule ^(/)?$ wordpress/index.php [L]
</IfModule>
 

AlbaHost

Well-known member
Moderator
Hosting Provider
Joined
Jan 18, 2017
Messages
777
Points
43
Just curious, what webserver are you using, apache, litespeed, nginx?
 

Philippe Gaucher

Well-known member
Collaborate
Registered
Joined
Jul 27, 2016
Messages
184
Points
18
Let's get straight to the point with some code magic to fix your issue:

Hide the /wordpress in the URL: Update your .htaccess file with this snippet:

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/wordpress/
RewriteRule ^(.*)$ /wordpress/$1 [L]
</IfModule>
This tweak tells your server to serve the content from the /wordpress folder without showing /wordpress in the browser's address bar.

Fix the internal links issue: Head over to your WordPress dashboard, navigate to Settings > General, and ensure your WordPress Address (URL) is http://abc.com/wordpress and your Site Address (URL) is http://abc.com. This setup instructs WordPress to keep its files in the /wordpress directory but makes the site appear to be hosted directly on abc.com.

Give these changes a whirl, and your site should behave just as you want, showing clean URLs without the /wordpress part. Don't forget to clear your cache before testing to see the changes in action!
 

NetedgeTec

Member
Registered
Joined
Feb 5, 2024
Messages
22
Points
1
To remove "/wordpress" from your website URL and avoid redirect loops:
  1. Update your .htaccess file with the provided code.
  2. In WordPress settings, change both "WordPress Address (URL)" and "Site Address (URL)" to https://abc.com.
  3. Update permalink structure under Settings > Permalinks.
  4. Clear browser cache and cookies to see the changes take effect.
 

NetedgeTec

Member
Registered
Joined
Feb 5, 2024
Messages
22
Points
1
Use this code for .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php$ - [L]

# Exclude "wordpress" folder from rewriting
RewriteCond %{REQUEST_URI} !^/wordpress/

# Redirect requests to "/wordpress" folder
RewriteRule ^(.*)$ /wordpress/$1 [L]

# Redirect requests for the root to WordPress
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^(.*)$ /wordpress/ [L]

# WordPress rules
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
 
Newer Threads
Replies
5
Views
459
Replies
7
Views
331
Replies
6
Views
427
Replies
4
Views
417

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top