I two domains. domainA.co.uk and domainB.co.uk
domainA.co.uk is the main site. this is where all the files are, including the htaccess file
domainB.co.uk is not hosted on the same server, but the DNS A record is pointing to the domainA.co.uk IP address.
Is it possible to redirect domainB.co.uk to domainA.co.uk/page?
On domainB.co.uk pointing host enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.co\.uk$ [NC]
RewriteRule ^ http://domainA.co.uk%{REQUEST_URI} [R=301,L]
Add this to your .htaccess in your web root / directory of domainA.co.uk
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?domainB\.co\.uk$ [NC]
RewriteCond %{REQUEST_URI} !^/page [NC]
RewriteRule ^(.*)$ page/$1 [L]
Related
Like the title says, I need to redirect from a subdomain with a subfolder to a different domain. It's important the full url is written from the subdomain, because I have more subdomains that need redirection.
I've tried the following:
RewriteCond %{HTTP_HOST} ^sub-domain.com/en/folder/subfolder/1$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/folder/subfolder-12602124/ [R=301,L]
But this doesnt seem to work.
I can't redirect from the root because multiple domains are on this root sadly...
Try this:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [NC]
RewriteRule ^subdirectory/?$ http://newurl.com [L,R=301,NC]
htaccess how to redirect subdirectory to external URL
When I access my site via www.domain.com/index.php or www.domain.com/index.html, it needs to redirect to www.domain.com for SEO purposes.
How do I configure this in .htaccess?
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} /(index)|(home)(..{3,4})?$ [NC]
RewriteRule ^([^/]+/)+ http://www.example.com/$1? [R=301,L]
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
DirectoryIndex index.html index.php
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteRule ^index\.(html?|php)$ / [L,R=301,NC]
I would like that the .htaccess don't add the SSL on the home link
http://domain.com
but on every other links in the website
https://domain.com/folder/index.html
So only the home page would not be secure. What the best .htaccess config for that ?
Thanks
Use RewriteRule to match that anything is present beyond the / and if matched, rewrite to SSL:
RewriteEngine On
# If ssl is not already active
RewriteCond %{HTTPS} !=on
# .+ matches one or more of any character... An empty string would not match
RewriteRule ^(.+)$ https://%{HTTP_HOST]}%{REQUEST_URI} [L,R=301]
Enable mod_rewrite and .htaccess through httpd.conf and then put this code in your .htaccess under DOCUMENT_ROOT directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^.+$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} =on
RewriteRule ^$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
I am trying to redirect my site from non-www to www. My site is at [http://www.alennuskoodit.us]. I try to make it so that all requests without www would be redirected to www. Normal stuff so far.
However, if I go to http://alennuskoodit.us I end up here: http://www.alennuskoodit.us/index.php?qstr=http://www.alennuskoodit.us
This is the .htaccess:
Options +FollowSymLinks
Options +Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
# going to install folder
RewriteCond %{REQUEST_URI} (.*)/install/?$
RewriteRule ^(.*)$ %1/install/index.php [NE,R,L]
# going to Admin folder
RewriteCond %{REQUEST_URI} (.*)/admin/?$
RewriteRule ^(.*)$ %1/Admin/index.php [NE,R,L]
# working with client side
RewriteRule ^(.*)/$ index.php?qstr=$1 [L]
</IfModule>
This is what I tried, which doesn't work:
RewriteCond %{HTTP_HOST} ^alennuskoodit.us [NC]
RewriteRule ^(.*)$ http://www.alennuskoodit.us/$1 [R=301,NC,L]
How could I redirect all queries to http://alennuskoodit.us to http://www.alennuskoodit.us so that I would not end up breaking the other rewrites?
Place your new rule before all the other rules i.e
Options +FollowSymLinks
Options +Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{HTTP_HOST} ^alennuskoodit.us$ [NC]
RewriteRule ^(.*)$ http://www.alennuskoodit.us/$1 [R=301,NC,L]
#other rules here
and it should prevent the qstr= param
Step1= You Must Use This Code In htaccess File To Preferred www Version:
RewriteCond %{HTTP_HOST} !^(.).YourDomain.com$ [NC] RewriteRule ^(.)$ http://www.YourDomain.com/$1 [R=301,L]
Step2= You Must Setting Your Preferred Domain In Google WebMaster Tools :
Open up your webmaster tools and click “Settings” right below “Configuration”. To the right look for the “Preferred Domain” and select which domain you prefer With www Or Not.
Our site have this url
http://mydomain.com/blog.php?id=50
and need redirect its by 301 to
http://blogs.mydomain.com/blog.php?id=50
must create sub domain or folder or can we do it directly .htaccess file ?
Try the following in your .htaccess file
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain\.com [NC]
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^blog\.php$ http://blogs.mydomain.com/blog.php?id=%1 [L,R=301]