Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

.htaccess Domain Redirect's

Featured Replies

Hi there people first postI want all domain address to redirect to https://www.stiffnights.co.uk

So if a user types in the browsers address bar like the following below :-

 

http://stiffnights.co.uk

https://stiffnights.co.uk

www.stiffnights.co.uk

stiffnights.co.uk

http://www.stiffnights.co.uk

 

It should transfer all the above in BLUE to https:\\www.stiffnights.co.uk

 

Is that possible would I have to edit the .htaccess file please help.

 

Thanks

is this any use to you

 

RewriteEngine On

RewriteCond %{HTTP_HOST} ^example.com

RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Options +FollowSymLinks
DirectoryIndex index.php

RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

 

if you are using an html extension on the home page chage the index.php to index.html in all places

 

and change

www.example.com to your domain name

Edited by ELITE

  • Author

Thank you elite

 

From the way it looks how would that work for me? Im not sure if this is write like I explained When the user type my domain address in the following formats

 

http://stiffnights.co.uk

https://stiffnights.co.uk

www.stiffnights.co.uk

stiffnights.co.uk

http://www.stiffnights.co.uk

 

I want it to auto transfer to https://www,stiffnights.co.uk

 

Thanks

try this

RewriteEngine On

RewriteCond %{HTTP_HOST} ^stiffnights.co.uk

RewriteRule (.*) https://www.stiffnights.co.uk/$1 [R=301,L]

Options +FollowSymLinks
DirectoryIndex index.html

RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ https://www.stiffnights.co.uk/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]

 

 

looks like you do have an html file for the homepage put the above in the top of your htaccess file but back your htaccess file up first

 

edit sorry this is just going redirect you to www.stiffnights.co.uk willl look into this if no one else can help

Edited by ELITE

  • Author

I know thanks but I want all to redirect

 

Example:

 

If I type http://stiffnights.co.uk should transfer to https://www.stiffnights.co.uk'>https://www.stiffnights.co.uk'>https://www.stiffnights.co.uk

if I type http://www.stiffnights.co.uk should transfer to https://www.stiffnights.co.uk

 

And so on.

 

All should automatically trasnfer to SSL link https://www.stiffnights.co.uk

i have it working for www. and http://www. will work on the rest tonight htaccess is not my stongest

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.stiffnights.co.uk/$1 [R,L]

 

i will work on the rest tonight when baby is in bed

This should do all but one of them

 

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.stiffnights.co.uk/$1 [R,L]

 

this is doing all that you want except https://stiffnights.co.uk

 

I will try this later

  • Author

For some reason I upload the new htaccess file with the new script you provide.

 

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.

RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{SERVER_PORT} 80

RewriteRule ^(.*)$ https://www.stiffnights.co.uk/$1 [R,L]

 

I have the feeling my htaccess file is not executed I don't know driving my head in.

your using

http://www.1and1.co.uk/

 

i would contact them ask if mod_rewrite is enabled are you on a windows server?

just making sure

 

I have the feeling my htaccess file is not executed I don't know driving my head in.

 

you do have a dot first .htaccess just making sure

  • Author

Ok after a little organizing this is my result.

 

My .htaccess file is as follows:-

DirectoryIndex index.html index.php

 

# Use PHP5 Single php.ini as default

AddType x-mapp-php5 .php

 

RewriteEngine On

RewriteCond %{http_host} ^mydomain.co.uk [nc]

RewriteCond %{http_host} ^mydomain.co.uk [nc]

RewriteRule ^(.*)$ https://www.mydomain.co.uk/ [r=301,nc]

RewriteCond %{SERVER_PORT} 443

 

Now the results:-

mydomain.co.uk ---> transfers to www.mydoamin.co.uk

mydomain.co.uk/ ---> transfer to https://www.mydomain.co.uk

 

www.mydoamin.co.uk ---> same no change www.mydoamin.co.uk

 

http://mydomain.co.uk ---> transfers to www.mydomain.co.uk

 

Now I think I have found out why it playing funny.

If all of these are type in as follows:

 

http://mydomain.co.uk/

https://mydomain.co.uk/

www.mydomain.co.uk/

mydomain.co.uk/

http://www.mydomain.co.uk/

 

They all transfer to https://www.mydomain.co.uk.

The problem is a forward slash has to be present for the redirect to work.

 

Is it possible to leave the .htaccess code the way it is and add more code so when the domains are typed in the address bar with out the forward slash they will also work to.

 

Hope this is useful sorry for being a pest but I have to resolve this.

 

Thank you

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.