Forum Moderators: phranque
I recently migrated to a new host provider and installed my site in a folder within the httpdocs folder. To get it all to work I cobbled together the following .htaccess file, but while the site works okay, the URL is showing as:
[MyDomain.com...]
I'd like to remove the /MyDomains reference but don't know how.
Here is the .httaccess file:
Options +FollowSymLinks
RewriteEngine On
rewritebase /
# handle domain root and skip subfolders
RewriteCond %{HTTP_HOST} www.MyDomain.com
RewriteCond %{REQUEST_URI} !^/MyDomain/
RewriteCond %{REQUEST_URI} \..+$
RewriteRule ^(.*)$ MyDomain/$1 [L]
RewriteCond %{HTTP_HOST} ^MyDomain.com [NC]
RewriteRule ^(.*)$ [MyDomain.com...] [L,R=301]
# add trailing slash to subfolders (eg abc to: abc/)
RewriteCond %{HTTP_HOST} www.MyDomain.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} [^/]$
RewriteRule ^(.*)$ $1/ [L,R=301]
# handle files in subfolders
RewriteCond %{HTTP_HOST} www.MyDomain.com
RewriteCond %{REQUEST_URI} !^/MyDomain/
RewriteRule ^(.*)$ MyDomain/$1/ [L]
Any help would be much appreciated.
The URL you see in your browser is the URL you link to on your page. You must edit your pages or the script that generates your pages to remove the /MyDomain URL-path-part, and then your mod_rewrite code will add it back in when converting the URL to a server filepath.
Jim