Subdirectory install with .htaccess and absolute path issues.
-
Hello all, new WP guy here.
I’ve searched the forums and the web extensively and I’ve been toying around with the code for a couple of days now to no avail. And if this question has already been asked or if someone can point me in the right direction, I’d greatly appreciate it.
I hate to write so much about a simple problem, but I figure it’s better to be descriptive than to ask a vague question, so here I go:
I’m hosting several websites with a single webhost. At the document root, I have multiple directories inside the document root. I use an htaccess file to redirect the domains to the proper directory and everything works well.
Here’s the .htaccess file that I’m using.
... #Add slashes RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.*)/$ RewriteRule ^(.*[\?]*.*)$ $1/ [L] #My first site... RewriteCond %{HTTP_HOST} ^example\.?com [NC,OR] RewriteCond %{HTTP_HOST} ^www.example\.?com [NC] RewriteCond %{REQUEST_URI} !/examplecom/ RewriteRule ^(.*)$ examplecom/$1 #My second site... RewriteCond %{HTTP_HOST} ^anotherexample\.?com [NC,OR] RewriteCond %{HTTP_HOST} ^www.anotherexample\.?com [NC] RewriteCond %{REQUEST_URI} !/anotherexamplecom/ RewriteRule ^(.*)$ anotherexamplecom/$1 #my third site, and so on. ...
So the above file redirects anything from example.com to a directory examplecom. When the user types in example.com into the directory, they see example.com, and not example.com/examplecom/.
That all works fine.
Now I installed wordpress into a subdirectory, so the location is examplecom/blog/, however, using the .htaccess file, I can access it directly by going to example.com/blog and it works perfectly.
The problem is that all the links in the wordpress seem to be using the absolute path. The user sees my directory structure, which I’d prefer to keep hidden. So, after clicking on a few links on the site, the user sees in the location bar: https://example.com/examplecom/blog/blah
Question:
Is there anyway to change this layout so it will not display the examplecom in the URL?I’ve tried messing around with my .htaccess file to no avail, I’ve tried looking into relative links, permalinks and even modified the ABSPATH constant in numerous PHP files in attempt to get a relative path, but I couldn’t get it to work. I would prefer not to change my directory structure because I’m hosting a lot of sites, and it would be a hassle to configure all of them again.
Any insight would be greatly appreciated.
Thanks!
- The topic ‘Subdirectory install with .htaccess and absolute path issues.’ is closed to new replies.