Reputation: 871
I've accidentally replaced our website's htaccess file yesterday and messed a couple of things up. I've been able to get the site back online, however, now, my site is showing the server's folder structure in the URL for all of the website's pages.
Desired:
http://gemdigitalagency.com/our-services
What is showing:
https://gemdigitalagency.com/production/gemdigitalagency/our-services/
I'd like to remove the /production/gemdigitalagency from the URL.
Here's what I have for htaccess (hosted in public_html):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^gemdigitalagency\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://gemdigitalagency.com/$1 [R,L]
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?gemdigitalagency.com$
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /production/gemdigitalagency/$1 [L]
RewriteCond %{HTTP_HOST} ^(www.)?gemdigitalagency.com$
RewriteRule ^(/)?$ production/gemdigitalagency/index.html [L]
ErrorDocument 400 /404.html
ErrorDocument 401 /404.html
ErrorDocument 403 /404.html
ErrorDocument 404 /404.html
ErrorDocument 500 /404.html
Options -Indexes
Could anyone please point me to the right direction? Thank you!
Upvotes: 1
Views: 237
Reputation: 871
We ended up removing a couple of things and adding an htaccess to the website's folder contents on the server.
htaccess in the public_html folder:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^gemdigitalagency\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://gemdigitalagency.com/$1 [R,L]
ErrorDocument 400 /404.html
ErrorDocument 401 /404.html
ErrorDocument 403 /404.html
ErrorDocument 404 /404.html
ErrorDocument 500 /404.html
Options -Indexes
htaccess in the website's folder:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^gemdigitalagency\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://gemdigitalagency\.com/$1 [R,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.gemdigitalagency\.com$ [NC]
RewriteRule ^(.*)$ https://gemdigitalagency\.com/$1 [R=301,L]
ErrorDocument 403 /404.html
ErrorDocument 404 /404.html
ErrorDocument 500 /404.html
Upvotes: 1
Reputation: 511
This will redirect user to SSL secured web http://...
onto https://
RewriteEngine On
RewriteCond %{HTTP_HOST} ^gemdigitalagency\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://gemdigitalagency.com/$1 [R,L]
This is where is your main issue
RewriteRule ^(.*)$ /production/gemdigitalagency/$1 [L]
RewriteRule ^(/)?$ production/gemdigitalagency/index.html [L]
which tells apache to rewrite everything going on host www.gemdigitalagency.com
OR gemdigitalagency.com
(www is optional)
RewriteCond %{HTTP_HOST} ^(www.)?gemdigitalagency.com$
to with something more in the URI
RewriteCond %{REQUEST_URI} !/$
which is not actual filename or directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
rewrite to /production/gemdigitalagency/$1
where the $1
is anything behind a host (https://gemdigitalagency.com/something?get_param=1) the $1
is something?get_param=1
for example
try to change it to:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^gemdigitalagency\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://gemdigitalagency.com/$1 [R,L]
RewriteCond %{HTTP_HOST} ^(www.)?gemdigitalagency.com$
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /$1 [L]
RewriteCond %{HTTP_HOST} ^(www.)?gemdigitalagency.com$
RewriteRule ^(/)?$ /index.html [L]
ErrorDocument 400 /404.html
ErrorDocument 401 /404.html
ErrorDocument 403 /404.html
ErrorDocument 404 /404.html
ErrorDocument 500 /404.html
Options -Indexes
Upvotes: 0