I have the following htaccess settings and my purpose is that bacchusbreak.com and www.bacchusbreak.com should redirect to my shopify website, except the faq folder.
bacchusbreak.com/faq works, but, www.bacchusbreak.com/faq gives 404.
Any thoughts? :)
RewriteOptions inherit
RewriteEngine on
RewriteCond %{HTTP_HOST} ^bacchusbreak\.com$ [NC]
RewriteCond %{HTTP_HOST} ^www\.bacchusbreak\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/faq/
RewriteRule ^(.*)$ "http\:\/\/wholesailors\.myshopify\.com\ \/" [R=301,L]
This should work:
RewriteOptions inherit
RewriteEngine on
# Combine the original two lines into one line, making "www." optional
RewriteCond %{HTTP_HOST} ^(www\.)?bacchusbreak\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/faq/
# No quotes needed around the destination URL
RewriteRule ^(.*)$ http://wholesailors.myshopify.com [R=301,L]
Related
I have two domain names for the same website, and need to do a correct rewrite, so that whenever someone accesses the first domain name and all subdirectories, with, or without www. they get redirected to the second domain and subdirectories without www.
I managed to set the redirect for the domain name without subdirectories, but for whatever reason, subdirectories are not getting rewritten.
So when I go to domainnamenumberone.com, or www.domainnamenumberone.com, i get redirected to domaintwo.com – however, when I go to domainnamenumberone.com/wordpress/path or www.domainnamenumberone.com/wordpress/path I remain there, and nothing gets rewritten.
Here's what I placed in .htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.domainnumberone\.com [NC]
RewriteRule ^(.*)$ http://domaintwo.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^domainnumberone\.com [NC]
RewriteRule ^(.*)$ http://domaintwo.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.domaintwo\.com [NC]
RewriteRule ^(.*)$ http://domaintwo.com/$1 [L,R=301]
Would be grateful for your help!
You need to place this rule as very first rule in DocumentRoot/.htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domaintwo\.com [NC,OR]
RewriteCond %{HTTP_HOST} ^(?:www\.)?domainnumberone\.com [NC]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(\S*)\s [NC]
RewriteRule ^ http://domaintwo.com/%1 [L,R=302,NE]
Then add this line in each child .htaccess like wordpress/ or wordpress/path/ (wherever .htaccess already exists) below RewriteEngine On line
RewriteOptions Inherit
You can use that:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\. [NC,OR]
RewriteCond %{HTTP_HOST} ^domainnumberone\.com [NC]
RewriteRule ^(.*)$ http://domaintwo.com/$1 [L,R=301]
But it seems to me that it should also work with yours.....
try a different browser (cache problem)
I have a htaccess set-up as such:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old\.co\.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www\.old\.co\.uk$
RewriteRule ^(.*)$ "http\:\/\/www\.new\.co\.uk\/$1" [R=301,L]
Which, to me at least, should forward everything to new.co.uk
However it does not forward the root (which I want it to) so if you go to
www.old.co.uk
Nothing happens but
www.old.co.uk/a
Redirects to new.co.uk
Can you try this rule:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?old\.co\.uk$ [NC]
RewriteRule ^ http://www.new.co.uk%{REQUEST_URI} [R=301,L]
I've been searching for this but I'm really newbie with .htacces (I find it a hell) and I cannot get the way to solve this.
I have the root folder in my server, redirecting the default domain URL to the folder "web". I have another folder, let's say subfold, and inside this, I have another folder: mobile.
What I want is that if someone types www.adomain.com it goes to root/subfold, without showing the subfold. I've done it this way:
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.adomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/subfold/ [NC]
RewriteRule (.*)$ /subfold/$1 [L]
RewriteCond %{HTTP_HOST} www\.maindomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/web/ [NC]
RewriteRule (.*)$ /web/$1 [L]
However, when I go to www.adomain.com/mobile it shows in the URL www.adomain.com/subfold/mobile/
My aim is that if I go to the mobile subfolder, in the URL it should show www.adomain.com/mobile
Obviously, I would like not to have to write a redirect everytime I add a subfolder, it it was possible.
How should I do that?
Thanks for your time and help!
You're getting redirected because your accessing a directory without a trailing slash. The mod_dir module, on by default, will redirect the browser and add a trailing slash if someone tries to access a directory without a trailing slash. This is because there is a information disclosure issue with indexing directories. You can either turn this off:
DirectorySlash Off
and risk having the contents of your directories get listed, even if there's an index.html file. Or add a bunch of rules to ensure there's a trailing slash:
RewriteEngine on
Options +FollowSymLinks
RewriteBase /
# redirect for trailing slash:
RewriteCond %{HTTP_HOST} ^www\.adomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/subfold/ [NC]
RewriteCond %{DOCUMENT_ROOT}/subfold%{REQUEST_URI} -d
RewriteRule (.*[^/])$ /$1/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.adomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/subfold/ [NC]
RewriteRule (.*)$ /subfold/$1 [L]
# redirect for trailing slash
RewriteCond %{HTTP_HOST} www\.maindomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/web/ [NC]
RewriteCond %{DOCUMENT_ROOT}/web%{REQUEST_URI} -d
RewriteRule (.*[^/])$ /$1/ [L,R=301]
RewriteCond %{HTTP_HOST} www\.maindomain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/web/ [NC]
RewriteRule (.*)$ /web/$1 [L]
I needed to redirect my od domain to a new one. All paths are same on both domains except the front page, which needed to be redirected from www.mydomain.com to www.mydomain2.com/newpath. I googled and came up with this code which works. My question is if it is valid and if all pageranks will be transfered without problems. Thank you
RewriteEngine on
RewriteCond %{HTTP_HOST} domain\.com [NC]
RewriteCond %{REQUEST_URI} ^/$
Rewriterule ^(.*)$ http://www.domain1.com/folder/ [L,R=301]
RewriteRule ^(.*)$ http://www.domain1.com/$1 [L,R=301]
Your code should work but it can be fine tuned a bit. Please consider this refactored code:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
Rewriterule ^$ http://www.domain1.com/folder/ [L,R=301]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^ http://www.domain1.com%{REQUEST_URI} [L,R=301]
I'm hoping someone can assist me with a mod_rewrite rule to redirect dynamic urls pointing to "videos.php" on my server to the base url.
For example, I need to redirect 'website.com/1/music/various/videos.php?=1234'
to 'website.com/videos.php?=1234'
edit: I am looking for a dynamic solution. If a url is pointed to videos.php at any time, I need to do a 301 redirect to home directory. Ie if /1/home/music/videos.php?=1234 redirect to /videos.php?=1234, or /music/playlist/1234/videos.php?1432 to /videos.php?1432.
Create a .htaccess file and insert these lines:
RewriteEngine On
# Page moved permanently:
RewriteRule ^videos\.php\?\=([0-9]+)\.html$ /1/music/various/videos.php?=$1 [R=301,L]
When testing, leave out the R=301, part, or you'll only see cache contents for a long, long time. Add it when sure its working fine. Or use 302, which means temporarily.
Please check this:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/1/music/various/videos.php$
RewriteCond %{QUERY_STRING} (.+)$
RewriteRule ^(.*) /videos.php [R,QSA]
RewriteCond %{REQUEST_URI} ^/videos.php$
RewriteCond %{QUERY_STRING} !(.+)$
RewriteRule ^(.*) http://%{HTTP_HOST}/ [R=301]
If it's not work, then try this:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/1/music/various/videos.php$
RewriteCond %{QUERY_STRING} ^(.+)$
RewriteRule ^(.*) /videos.php%1 [R]
RewriteCond %{REQUEST_URI} ^/videos.php$
RewriteCond %{QUERY_STRING} !(.+)$
RewriteRule ^(.*) http://%{HTTP_HOST}/ [R=301]