Monday, November 4, 2013
Apache mod_rewrite tutorial links
Meaning and Purpose of Apache mod_rewrite module.
http://net.tutsplus.com/tutorials/other/a-deeper-look-at-mod_rewrite-for-apache/
http://www.sitepoint.com/guide-url-rewriting/
http://www.sitepoint.com/apache-mod_rewrite-examples/
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
https://www.digitalocean.com/community/articles/how-to-set-up-mod_rewrite
http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html
http://www.elated.com/articles/mod-rewrite-tutorial-for-absolute-beginners/
http://www.penguintutor.com/linux/apache-mod_rewrite
http://edrackham.com/apache/beginners-mod_rewrite-tutorial/
What is httpd.conf?
httpd.conf is a configuration file which is used by the Apache HTTP Server. It stores information on various functions of the server, which can be edited by removing or adding a number sign "#" at the beginning of the line, thus setting values for each directive. (refer http://en.wikipedia.org/wiki/Httpd.conf)
Follow tutorial on httpd.conf here, http://php-steps.blogspot.com/2013/11/wampserver-and-apache-httpdconf.html
Meaning and Purpose of Apache mod_rewrite module
REWRITE ENGINE
Meaning:A rewrite engine is software located in a Web application framework running on a Web server that modifies a web URL's appearance. This modification is called URL rewriting. Rewritten URLs (sometimes known as short, fancy URLs, search engine friendly - SEF URLs, or slugs) are used to provide shorter and more relevant-looking links to web pages. The technique adds a layer of abstraction between the files used to generate a web page and the URL that is presented to the outside world. (refer http://en.wikipedia.org/wiki/Mod-rewrite)
Purpose:
The purpose of the rewrite engine is to rewrite a visitor’s request URI in the manner specified by a set of rules. (refer http://www.sitepoint.com/apache-mod_rewrite-examples/)
Benefits:
- The links are "cleaner" and more descriptive, improving their "friendliness" to both users and search engines.
- They prevent undesired "inline linking", which can waste bandwidth.
- They hide the inner workings of a web site's address to visitors, which can prevent them from discovering query strings that could compromise the site.
- The site can continue to use the same URLs even if the underlying technology used to serve them is changed (for example, switching to a new blogging engine).
(refer http://en.wikipedia.org/wiki/Mod-rewrite)
APACHE mod_rewrite:
The
mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, mod_rewritemaps a URL to a filesystem path. However, it can also be used to redirect one URL to another URL, or to invoke an internal proxy fetch.mod_rewrite provides a flexible and powerful way to manipulate URLs using an unlimited number of rules. Each rule can have an unlimited number of attached rule conditions, to allow you to rewrite URL based on server variables, environment variables, HTTP headers, or time stamps.mod_rewrite operates on the full URL path, including the path-info section. A rewrite rule can be invoked in httpd.conf or in .htaccess. The path generated by a rewrite rule can include a query string, or can lead to internal sub-processing, external request redirection, or internal proxy throughput.(refer http://httpd.apache.org/docs/current/mod/mod_rewrite.html)
Guide: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
Example: http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
Friday, November 1, 2013
WampServer and Apache httpd.conf: ServerName, DocumentRoot, Directory and Alias
1) PREPARATION
2) SETUP
3) EDIT HTTPD.CONF
WampServer is a software suite that contains Apache, PHP and MySQL servers.
Apache server configuration is stored in a file called httpd.conf.
Amongst all, httpd.conf defines ServerName, DocumentRoot and Directory. These three items specify the physical location of any particular website, its name and its network access types.
1) PREPARATION
1.1) There are many kinds of Apache-MySQL-PHP suites and each suite may have different way of managing httpd.conf. For the purpose of this tutorial, we will be using WampServer version 2.0i.
1.4) We will be using Notepad++ as the text editor so that we can easily find specific line in the httpd.conf file. (Direct link to Notepad++ portable:http://downloads.sourceforge.net/project/portableapps/Notepad%2B%2B%20Portable/Additional%20Versions/NotepadPlusPlusPortable_6.5.paf.exe?r=http%3A%2F%2Fportableapps.com%2Fapps%2Fdevelopment%2Fnotepadpp_portable&ts=1383311986&use_mirror=jaist )
1.5) Optionally, you may need 7-zip portable in case you need to zip/unzip files later on. (Direct link to 7-zip portable:
2) SETUP
2.1) Follow http://php-steps.blogspot.com/2013/11/wampserver-download-setup-installation.html to setup WampServer installation.
3) EDIT HTTPD.CONF
3.1) Open the file. It is located in the {wamp home}\bin\apache\Apache2.2.11\conf.
3.2) By the default the ServerName, DocumentRoot, Directory are located at the following lines:
171. ServerName
178. DocumentRoot
205 - 236. Directory
3.2) Let’s say we want to change the DocumentRoot c:/wamp/www/mysite1/
3.2.1) Create the subfolder mysite1 under www folder.
3.2.2) Create a file index.php inside mysite1 folder and type the following codes into it:
<?php
echo “<h1>MySite1</h1”;
?>
3.2.3) Edit httpd.conf as follows:
Line no. 178: DocumentRoot “c:/wamp/www/mysite1/”
Line no. 205: <Directory “c:/wamp/www/mysite1/”>
3.2.4) Restart Apache.
Click Control Panel/Apache/Service/Restart Service.
3.2.5) Outcome:
3.3.) Let’s say we want to use a domain name mysite1.local instead of localhost.
3.3.1) If you type the URL http://mysite1.local now, you will get:
The computer doesn’t recognize the address. If your computer is connected to the Internet, probably you will be forwarded to a search engine instead.
3.3.2) We need to tell the computer the ip for mysite1.local, e.g. 127.0.0.1. Using notepad++, open the file c:\windows\system32\drivers\etc\hosts:
3.3.3) Go to the right of the localhost, type a space and type “mysite1.local” (without the quotes).
3.3.4) Save the file.
3.3.5) In httpd.conf file, replace the localhost with mysite1 at line no.171 as follows:
3.3.6) Restart your PC (for step 3.3.3 to take effect).
3.3.7) Go to URL http://mysite1.local/
3.4) An Alias is used to provide the alternative location for a directory under a domain.
3.4.1) For e.g., if you browse URL http://mysite1.local/phpmyadmin/ you will get the following:
3.4.2) Recall Step 3.2.1, the physical location mysite1 doesn’t contain phpmyadmin directory. So, where is the folder stored actually?
3.4.3) There is an entry in httpd.conf that includes a call to another configuration file located in “c:/wamp/alias/”
3.4.3) Go to the folder, you will see the file phpmyadmin.conf
3.4.4) Open the file and you will see the physical location of phpmyadmin. It was stored in c:/wamp/apps/phpmyadmin3.2.0.1/
3.4.5) By using an alias, a directory can be stored outside of a website directory and can be shared by many domains, e.g. mysite1/phpmyadmin, mysite2/phpmyadmin etc.
WampServer Download, Setup Installation and Getting Started
1) DOWNLOAD
2) SETUP INSTALLATION
3) GETTING STARTED
This tutorial demonstrates the installation process for WamServer2.0i
1) DOWNLOAD
1.2) Go to WampServer download page, http://sourceforge.net/projects/wampserver/files/WampServer%202/WampServer%202.0/
Notice that WampServer2.0i is the most popular version among others.
1.3) Download WampServer2.0i.exe (Direct Link: http://sourceforge.net/projects/wampserver/files/WampServer%202/WampServer%202.0/WampServer2.0i.exe/download )
2) SETUP INSTALLATION
2.1) Run the installer.
2.2) Accept the agreement
2.3) Accept default destination location.
2.4) Optionally, you may choose additional tasks.
2.5) Click Install.
2.6) Wait for the process to complete.
2.7) The installer may prompt you for default Web Browser.
Just accept the suggestion.
2.8) PHP Mail Parameters.
Leave them as they are for the time being.
2.9) Installation done.
3) GETTING STARTED
3.1) Continue from Step 2.9, unblock Apache service.
3.2) WampServer icon will appear in the tray.
3.3) Left-click the icon to see the menu.
(Put Online is to make your server accessible to other computers in the network. You do not have to Put Online now).
3.4) Click Localhost.
The Web Browser pops up and open the URL http://localhost
3.5) Click phpMyAdmin
The Web Browser pops up and open the URL http://localhost/phpmyadmin
3.6) Click www directory.
File Explorer pops up and open the Address C:\wamp\www
3.7) Let’s try each item on the Control Panel menu to see what they offer.
Warning: The magic method __isset() must have public visibility and cannot be static in
Warning: The magic method __isset() must have public visibility and cannot be static in
Subscribe to:
Posts (Atom)
Labels
apt-get
(2)
bash
(4)
Chrome
(1)
CMS
(1)
code-igniter
(1)
codenvy
(1)
composer
(6)
eclipse che
(1)
error
(4)
file-permission
(1)
firebase
(2)
Free PHP Hosting
(11)
FuelPHP
(3)
git
(4)
jwt
(1)
laravel
(10)
mysql
(1)
OpenShift
(1)
php
(11)
PHP Eclipse
(9)
PHP Joomla
(2)
PHP Laravel
(4)
PHP Yii
(9)
PHP-JBOSS
(2)
php-jwt
(2)
PHP-Wordpress
(8)
plain php
(1)
Postman
(1)
REST
(2)
sqlite
(1)
sudo
(1)
visual-studio
(4)
xampp
(4)



