Is it possible to make the website unavailable while editing it, while online?
If so, what is the method called and how is it done?
I have a webhosting company so it's not my own server!
Typically, people use the .htaccess to password protect it until you are ready to show it to the world
Here is a link to an article with instructions
http://www.elated.com/articles/password-protecting-your-pages-with-htaccess/
I had the same issue, I just put up a "coming-soon.html" page and redirected everyone without my IP there via htaccess, here's the question on SO: Want to redirect all visitors except for me [.htaccess]
Or, if it's ASP.Net - place a file called app_offline.htm in the site root.
If you are uploading a new version of the site you can create a symlink in the place of the root directory and then switch that when the site's ready. You can also switch the symlink back to the previous version if something goes wrong.
You can make an .htaccess file like this :
RewriteCond $1 !offline.html$
RewriteCond %{REMOTE_ADDR} !^your_ip_adress
RewriteRule ^(.*)$ http://www.mydomain.com/offline.html [R=302,L]
Simply put the files in a new directory and don't tell anybody else the name of the directory. (Or you can tell it to some beta testers if you like.)
When the pages are ready and tested, just move the files into the normal place (after moving the old existing files into backup directory). This way, you always have a working site online.
But generally, it is better to develop the web site on your local computer, not online.
Related
So I recently purchased a domain. I know how to make websites, so I uploaded a website that I made onto that domain. The only problem is is that it sends me to my index and then I have to click on some folders to actually get to see my website on my screen. I know what .htaccess is and does, but I'm not sure how to use it.
What I want is that when I go to www.mydomain.com it should open up my home.php file from the website that I made. This is my file order:
project/PHP/home.php
I'm not sure if I've given enough information, but I hope someone can help me out here.
As correctly written by #JimL in the comments above we would recommend that you simply replace home.php to index.php, since that is the default setting really all http servers are configured to use for the index document.
You can however change that, even if you can only use .htaccess style files:
DirectoryIndex home.php
That said I still would recommend to rename the index file instead. .htaccess style files should be avoided whenever possible. They are notoriously error prone, hard to debug and they really slow the http server down, often without reason. They are only offered for cases where you really need to do some configuration tweaks but do not have control over the http servers host configuration. That is for example often the case when using a cheap web space provider.
Considering the additional information you gave in the comment below you could also try to rewrite all requests to point to the php scripts inside that folder project/php. For that you can place such rewriting rules inside a .htaccess style file:
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/project/php
RewriteRule ^(.*)$ project/php/$1 [L,QSA]
If you also have to handle requests that require different rewriting then obviously you need additional rules.
But as already said in the comments below this is painful, slows the server down and makes things harder to debug.
Put your files in the public_html folder, or /var/www, you don't need the .htacces to do this.
i have a site abc.com in php and now made anothers site abcd.com on rails, i wish to redirect all requests that go to the php site to redirect to abcd.com...
example:
abc.com/page3 -> abcd.com/page3
abc.com/non_existing_link ->abcd.com
this php site is just hard coded, not using any framework and i wish to write script in index.php which would accept ny link towards abc.com and then check the extension and redirect it accordingly to the corresponding links on abcd.com... i was suggested to write a controller from a collegue and i am not familiar with mvc functionalities nor th controllers class and stuff...
If your webserver runs apache, I would recommend placing a .htaccess-file in the root of your original server as in the following answer: .htaccess redirect all pages to new domain. If you would like to keep the names the same (redirect to exactly the same name on your new domain), use the following lines:
RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,QSA]
This method works with very limited amount of work/coding :-)
I believe you there are several ways to achieve so:
Using php redirect in all php pages.
How to make a redirect in PHP?
Modifying .htaccess file in your directory
http://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F
If you have a cpanel of other controler system from hosting provider then do it directly there.
I've made a new website for a client who has an intranet integrated into their old website.
The new website is currently on a different server, but when the domain A records point to the new server, the old site (and intranet) will obviously not be accessible, but I need to keep their intranet active. The path to their intranet is: abc.com/intranet
Is there a way to have URL path direct to the old server? For example:
abc.com - new website loads on new server
abc.com/intranet - old website loads on older server
If it's not possible, I suppose I'm looking at creating a sub-domain on abc.com for the intranet. Any thoughts are appreciated.
You need to use an Apache RewriteRule using mod_rewrite. This can be placed in an .htaccess file on your server’s root or it can be placed directly into your Apache config file.
If you want to redirect example.com to example.com/intranet, then this is the Apache RewriteRule that should work for your needs:
RewriteEngine on
RewriteRule ^(.*)$ /intranet [L,R=301]
This will grab any URL on the site this RewriteRule is placed on & redirect them to /intranet. That /intranet can also be a full URL such as this example below:
RewriteEngine on
RewriteRule ^(.*)$ http://example.com/intranet [L,R=301]
EDIT: Upon rereading your question, I am not 100% sure the answer above works for you as-is. So I think if you are describing how to point one URL path from one server to another, you would do this. This gets placed on the new server:
RewriteEngine on
RewriteRule ^/intranet(.*)$ http://old_example.com/intranet [L,R=301]
That would grab any URL coming from new_example.com/intranet and redirect it to old_example.com/intranet.
ANOTHER EDIT: Since the original poster indicates the server will have the IP fully changed, then a subdomain for the old server is the best way to go. You can’t redirect content on one domain the way you describe if you switch the domains fully to different IP. Both servers need to be active with an active—but different—domain name for what you want to happen.
abc.com/intranet is a path in the virtual file system exposed by your web server, so is not possible to serve the content from different web server. You have 2 options here.
Put a reverse proxy in front of both servers and get the content from server A or B based on the original client request.
As you said, create a subdomain and also redirect /intranet to the new subdomain.
Hope this help!
Since I'm new to Joomla I would like to know whether there is a way to change the administrator URL by using PHP rather than using a plugin or extensions. As far as I see using a 3rd party component is risky. I really don't want to use 3rd party extensions at all in mysite. How can I get it done?
By default Joomla administrator URL is yoursitename/administrator.
changing constants in /includes/defines.php and /administrator/includes/defines.php does not work.
Thanks
referring this post you have got two options one through cpanel and other to use .htaccess..
From what I have read, you can't change the administrator URL however someone did post something regarding it on Stackoverflow.
Open the following files:
/includes/defines.php >> line 25
/administrator/includes/defines.php >> line 21
Else the only way might be using an extension.
Step 1. Create a new directory in your root directory (eg. "newadminurl")
Step 2. Create an index.php file in your "newadminurl " directory..
$admin_cookie_code="3429020892";
setcookie("JoomlaAdminSession",$admin_cookie_code,0,"/");
header("Location: /administrator/index.php");
?>
Step 3. Add this to .htaccess of your real Joomla administrator directory
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/administrator
RewriteCond %{HTTP_COOKIE} !JoomlaAdminSession=3429020892
RewriteRule .* - [L,F]
Explanation:
Now, you need to open "http://yoursite.com/newadminurl/" before you open your “administrator” path. Here we have created a cookie that expires at the end of the session and redirect to actual administration page. Your actual “administrator”path is inaccessible until you don’t open on your secret link .
I hope this is what you are looking for.
I'm developing some web based application based on PHP.
I have some folder structure that will be located inside the public html file.
I'd like to make it work so that when a user types for ex. http://mysite.com/ he/she gets into http://mysite.com/public but I don't want the user to know that he/she is inside public, the user should think that his directly inside public_html folder.
Any hints?
P.S. I'm doing it on hosted server, so I have access with only Cpanel, I'm not the admin of the server.
You either need to use mod_alias or mod_rewrite for this. How much of cPanel is available to you? How much does you host let you do?
I'll just have to have a look through my WHM server to work out how to do Aliases, but you can do rewrites with a .htaccess file. I would recommend Aliases over rewrites thought, as they are less complicated and less resource-hungry.
EDIT
Just been into my root login for our WHM/cPanel based server, and I can't find any way to use mod_alias - I think this is probably because it would require an Apache restart. You will have to use mod_rewrite.
Put this in a .htaccess file in public_html:
RewriteEngine on
RewriteRule (.*) public/$1 [L]
You can set up an addon domain and point it to /public_html/public directory.
Edit:
Parked domain should work too.