Link to home
Start Free TrialLog in
Avatar of meade470
meade470

asked on

.htaccess - Hiding the subdirectory using wordpress

Currently we have the following configuration on our .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /v2/index.php [L]
</IfModule>

# END WordPress

RewriteCond %{HTTP_HOST} ^meadeauto\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.meadeauto\.com$
RewriteRule ^/?$ "http\:\/\/www\.meadeauto\.com\/v2" [R=301,L]
RewriteCond %{HTTP_HOST} ^meadegroup\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.meadegroup\.com$
RewriteRule ^/?$ "http\:\/\/www\.meadeauto\.com" [R=301,L]
RewriteCond %{HTTP_HOST} ^meadelexus\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.meadelexus\.com$
RewriteRule ^/?$ "http\:\/\/www\.meadeauto\.com" [R=301,L]

Open in new window


When you visit www.meadeauto.com it shows www.meadeauto.com/v2 in the browser URL bar. We want it to show (rewrite): www.meadeauto.com in the URL bar.

We have tried various combinations, including this solution we found on a blog post:

RewriteBase /

# Add trailing slash if path does not contain a period or end with a slash
RewriteCond %{REQUEST_URI} !(\.|/$)
RewriteRule (.*) http://www.yoursite.com/$1/ [R=301,L]

#Change http://yoursite.com to http://www.yoursite.com (Optional)
RewriteCond %{HTTP_HOST} ^yoursite.com$
RewriteRule ^/?(.*)$ http://www.yoursite.com/$1 [R=301,L]
#Rewrites http://www.yoursite.com/subdir to http://www.yoursite.com/
RewriteCond %{REQUEST_URI} !^/subdir
RewriteRule ^(.*)$ subdir/$1 [L]

Open in new window


That seemed to change it to meadeauto.com in the url bar, but also broke www.gistroy.com (another domain, which is in the /gis/ folder on our main directory).
Avatar of eemit
eemit
Flag of Germany image

Insert this above the line:
# BEGIN WordPress

# protect "dir"
Options All -Indexes

Open in new window

Avatar of meade470
meade470

ASKER

eemit, unfortunately that is still showing the subdirectory (www.meadeauto.com/v2/) when loading meadeauto after making the change to:

# protect "dir"
Options All -Indexes

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /v2/index.php [L]
</IfModule>

# END WordPress

RewriteCond %{HTTP_HOST} ^meadeauto\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.meadeauto\.com$
RewriteRule ^/?$ "http\:\/\/www\.meadeauto\.com\/v2" [R=301,L]
RewriteCond %{HTTP_HOST} ^meadegroup\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.meadegroup\.com$
RewriteRule ^/?$ "http\:\/\/www\.meadeauto\.com" [R=301,L]
RewriteCond %{HTTP_HOST} ^meadelexus\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.meadelexus\.com$
RewriteRule ^/?$ "http\:\/\/www\.meadeauto\.com" [R=301,L]

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
routinet, thanks for the thorough response. We changed it to the following:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /v2/index.php [L]
</IfModule>

# END WordPress

RewriteCond %{HTTP_HOST} ^meadeauto\.com$ [NC]
RewriteRule ^/?(.*)$ http://www.meadeauto.com/$1 [R=301,L,QSA]
RewriteCond %{HTTP_HOST} ^www\.meadeauto\.com$ [NC]
RewriteRule ^/?$ /v2 [L]
RewriteCond %{HTTP_HOST} ^meadegroup\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.meadegroup\.com$
RewriteRule ^/?$ "http\:\/\/www\.meadeauto\.com" [R=301,L]
RewriteCond %{HTTP_HOST} ^meadelexus\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.meadelexus\.com$
RewriteRule ^/?$ "http\:\/\/www\.meadeauto\.com" [R=301,L]

Open in new window


but unfortunately were still getting the same results. Do you have any further recommendations/changes?
We completely re-wrote it and it now contains:

# The below settings will forward each incoming domain name to the respective
# folders. gis/ is gistroy.com and v2/ is meadeauto.com WP install
# RewriteEngine On
# RewriteCond %{HTTP_HOST} ^(www.)?domainname.com$
# RewriteRule ^(/)?$ subdir/index.php [L]

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?gistroy.com$
RewriteRule ^(/)?$ gis/index.php [L]

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?meadeauto.com$
RewriteRule ^(/)?$ v2/index.php [L]

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?meadelexus.com$
RewriteRule ^(/)?$ v2/index.php [L]

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?meadegroup.com$
RewriteRule ^(/)?$ v2/index.php [L]

# Added the below to prevent htaccess viewing and directory listings

<Files .htaccess>
order allow,deny
deny from all
</Files>

Options All -Indexes

 

Open in new window


It seems to work now! We used this resource from WP for it.

Any additional suggestions to spruce it up is appreciated.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial