Forum Moderators: phranque

Message Too Old, No Replies

.htaccess subfolder problem

htaccess,subfolder

         

Pingu

12:01 pm on Mar 3, 2009 (gmt 0)

10+ Year Member



Hi,

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.

jdMorgan

3:58 pm on Mar 3, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Put your rules in order: External redirects first, in order from most-specific pattern (fewest URLs affected) to least-specific pattern, followed by internal rewrites, again from most-specific to least-specific.

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