302 .htaccess redirect on joomla 1.5 - .htaccess

What's the best way to temporary redirect my entire site to a subdomain in joomla?
For example redirect mydomain.com (including all my website pages) to offline.mydomain.com.
What string should I add in .htaccess?
I want to be sure that all visitors are not able to visit mydomain.com and all subfolder and files when redirect is on.

You could place a .htacces with following content:
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1$
RewriteRule (.*) http://offline.mydomain.com/? [R=302,L]
so everybody except the User with IP 127.0.0.1 will get redirected by it.

Related

.htaccess redirect for https://.co.nz website to .com version(including all subpages)

I am palling to migrate my website from the .co.nz to the .com but need to setup a 301 redirect so all of the individual pages will still be routed properly without any 404 pages from .co.nz version
All https://
I want "https://www.example.co.nz/" to go to "https://www.example.com"
Which will also redirect
https://www.example.co.nz/contact to go to https://www.example.com/contact
https://www.example.co.nz/men to go to https://www.example.com/men
Many Thanks
This should do the trick:
Redirect 301 / https://www.new-example.com/
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !new-example.com$ [NC]
RewriteRule ^(.*)$ https://new-example.com/$1 [L,R=301]
You put this in the .htaccess file of the .co.nz domain. This will redirect all your content and subfolders to their appropriate subfolders on the new domain (so example.me/subfolder to example.com/subfolder) AND also force redirect to https part.

DNS 301 redirect issue

I implemented a DNS-level 301 redirect in my Namecheap console, which redirected my old sub-domain assets.websitename.com to websitename.com/assets.
However, when trying to access assets.websitename.com/css/main.css, the client will be redirected to websitename.com/css/main.css/assets. I intended to redirect the user to websitename.com/assets/css/main.css.
So my question is:
How can I properly configure the 301 redirect?
Apache
If using .htaccess or similar in Apache web server:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} assets.websitename.com$ [NC]
RewriteRule ^(.*)$ http://websitename.com/assets/$1 [L,R=301]
Namecheap
Since you're using the Namecheap control panel, try this:
Make sure you have a slash at the end of the IP Address / URL box. So it should look like this:
HOSTNAME IPADDRESS/URL REDIRECTTYPE
assets http://websitename.com/assets/ URL Redirect
notice the slash at the end of http://websitename.com/assets/

301 Redirect in .htaccess

I need to redirect my website to a new domain name but I want it to also redirect all of the pages. I want www.myoldsite.com/ to redirect to www.mynewsite.com/ but I also want all of the pages to redirect.
For example: www.myoldsite.com/faq to redirect to www.mynewsite.com/faq and so forth and so on. I know how to do it by doing each individual page but I have a lot of pages. How do I rewrite the 301 for it to basically change the root domain name but keep the directories and pages the same? Thanks a million!
You just need this in the htaccess file in your old domain's document root:
Redirect 301 / http://www.mynewsite.com/
If both your old site and new site share the same document root, then you need mod_rewrite instead:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?myoldsite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mynewsite.com/$1 [L,R=301]

htaccess redirect issue in godaddy

I have a htaccess which will redirect all subdomain to parent domain except one domain.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.theonlytutorials\.com$ [NC]
RewriteCond %1 !^(blog|www)$ [NC]
RewriteRule ^(.*)$ http://theonlytutorials.com/$1 [L,R=301]
This code was working fine in my previous hosting. But in Godaddy it doesn't seems to be working.
It is redirecting, but to the exact hosting location.
One of my URL structure:
www.theonlytutorials.com/video/58/4496/ChessBaseGmbH
Instead it is redirecting to:
www.theonlytutorials.com/others/tutorials/video/58/4496/ChessBaseGmbH
Where others / tutorials are the folders created in my hosting
On Go Daddy (and probably some other Hosts) the site folder names should be included in your redirect code.
RedirectMatch 301 ^/site-folder-name/video/58/4496/ChessBaseGmbH/$ http://the full URL here where you want the redirect point to
If you wanted to redirect a link from the /blog/ folder / site to another site
RedirectMatch 301 ^/blog/video/58/4496/ChessBaseGmbH/$ http://the full URL here where you want the redirect point to
Let's say you want to do a redirect from a site that is in this folder /others/ and you want to redirect to your root domain.
RedirectMatch 301 ^/others/video/58/4496/ChessBaseGmbH/$ http://the full URL here to your root domain where you want the redirect to point to
And logically the same thing would probably be true if you have this folder structure /others/another-nested-folder/
RedirectMatch 301 ^/others/another-nested-folder/video/58/4496/ChessBaseGmbH/$ http://the full URL here to your root domain where you want the redirect to point to

Problems with htaccess Redirect (Page on one domain to same page on another)

I'm trying to redirect a few pages to a new domain and I have done this before but for some reason I can't get the code to work.
RewriteEngine On
Redirect 301 http://domain.com/page1.html http://domain2.com/page1.html
Can anyone see where I'm going wrong?
In .htaccess file the below code will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
The .htaccess file needs to be placed in the root directory of your old website
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Since you say you only want to direct a FEW of your pages and not all of them, you can do:
RewriteEngine On
Redirect /~myaccount/oldpage.html http://www.newsite.com/newpage.html
You specify the path to the page on your current server followed by the URL to redirect to.
OR you can do:
RedirectMatch 301 ^/oldpage\.html$ http://www.newsite.com/newpage.html

Resources