C5 Installation Directory & Bluehost Primary Domain Redirect ion
Permalink
Ok, I have a Unix host with bluehost.
My problem is that the host and the dependency to have a primary domain mapped to /public_html but sub-domains and addon domains can map to folders no problem.
Bluehost refuse to manually edit the httpd.conf file so I can resolve my primary domain to it's own folder.
I tried using .htaccess to essentially do this for me and I think it would work fine except that my site is written primarily in php which causes the dynamic links to look messy.
for example, I can type:
http://mydomain.com
http://www.mydomain.com
http://www.mydomain.com/index.php...
etc, just fine, but all of the links on my site generated by PHP show up with the folder in the path, for example, my about page link looks like this:
http://www.mydomain.com/mydomain/about/...
If I manually typehttp://www.mydomain.com/about in the address bar it works just fine, it's just my links do not omit the folder in the path, which also result in my sitemap and bots crawling my site with undesirable long links.
i.e. here is my .htacces in /public_html/
-------------------------------------------
Code:
# -Begin custom settings
Options -Indexes
DirectorySlash Off
DirectoryIndex index.html index.php
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$http://www.mydomain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteCond %{REQUEST_URI} !^/www\.mydomain\.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /mydomainsubdirectorywitinpublichtml/$1
# Add a trailing slash onto directories so the DirectoryIndex search works.
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} !/$
RewriteRule ^(.*)$ $1/ [L]
# ...except for /. This one we have to hard code to a specific file.
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^ index.php
#End custom settings.
-------------------------------------------
Then in my public_html/mydomainsubdirectorywithinpublic_html/ .htaccess file I added this to turn on clean urls:
-------------------------------------------
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mydomainsubdirectorywithinpublic_html/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
------------------------
Is there any way to keep my site links from showing it is installed in a folder without having to go through all the php code in my site and write custom php stripping code into any possible dynamic links?
Thanks for any and all feedback.
My problem is that the host and the dependency to have a primary domain mapped to /public_html but sub-domains and addon domains can map to folders no problem.
Bluehost refuse to manually edit the httpd.conf file so I can resolve my primary domain to it's own folder.
I tried using .htaccess to essentially do this for me and I think it would work fine except that my site is written primarily in php which causes the dynamic links to look messy.
for example, I can type:
http://mydomain.com
http://www.mydomain.com
http://www.mydomain.com/index.php...
etc, just fine, but all of the links on my site generated by PHP show up with the folder in the path, for example, my about page link looks like this:
http://www.mydomain.com/mydomain/about/...
If I manually typehttp://www.mydomain.com/about in the address bar it works just fine, it's just my links do not omit the folder in the path, which also result in my sitemap and bots crawling my site with undesirable long links.
i.e. here is my .htacces in /public_html/
-------------------------------------------
Code:
# -Begin custom settings
Options -Indexes
DirectorySlash Off
DirectoryIndex index.html index.php
ErrorDocument 403 /403.php
ErrorDocument 404 /404.php
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$http://www.mydomain.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$
RewriteCond %{REQUEST_URI} !^/www\.mydomain\.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /mydomainsubdirectorywitinpublichtml/$1
# Add a trailing slash onto directories so the DirectoryIndex search works.
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_FILENAME} !/$
RewriteRule ^(.*)$ $1/ [L]
# ...except for /. This one we have to hard code to a specific file.
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^ index.php
#End custom settings.
-------------------------------------------
Then in my public_html/mydomainsubdirectorywithinpublic_html/ .htaccess file I added this to turn on clean urls:
-------------------------------------------
Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mydomainsubdirectorywithinpublic_html/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
------------------------
Is there any way to keep my site links from showing it is installed in a folder without having to go through all the php code in my site and write custom php stripping code into any possible dynamic links?
Thanks for any and all feedback.
I'm not sure if this helps, or if the information in this doc still creates the same issue - but I'd thought I'd post it anyway since I had it bookmarked:
How to host the Primary Domain from a subfolder (.htaccess)
http://helpdesk.bluehost.com/index.php/kb/article/000347...
How to host the Primary Domain from a subfolder (.htaccess)
http://helpdesk.bluehost.com/index.php/kb/article/000347...
I really hope someone manages to answer this because this situation is VERY common for those of us on Bluehost, and I really don't want to revert to hosting the primary domain from the usual document root.