meade470
asked on
.htaccess - Hiding the subdirectory using wordpress
Currently we have the following configuration on our .htaccess file:
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:
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).
# 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]
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]
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).
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]
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
routinet, thanks for the thorough response. We changed it to the following:
but unfortunately were still getting the same results. Do you have any further recommendations/changes?
# 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]
but unfortunately were still getting the same results. Do you have any further recommendations/changes?
ASKER
We completely re-wrote it and it now contains:
It seems to work now! We used this resource from WP for it.
Any additional suggestions to spruce it up is appreciated.
# 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
It seems to work now! We used this resource from WP for it.
Any additional suggestions to spruce it up is appreciated.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
# BEGIN WordPress
Open in new window