Well Ollllo there!!!!
So you have started creating your own project and i guess you’re wondering how to shortcut your project.
(For those who wonders “what is ‘aliasing’ directory”?)
To be short,
let say you have created a project “E:\Program Files\xampp\htdocs\blah\\trunk\myproject\app\”,
so… what do you do to load up in browser “http://localhost/blah/trunk/myproject/”. You might not feel it in the beginning, but as start to become curious (and lazy or wanna be quick), you could do like “http://localhost/myproject”
Ofcourse, you could just put your project directly in htdocs which might makes thing simple, buut… as we create more and more projects, we need to organize or need to use SVN or GIT, and need to follow their folder structure, so, you NEED to shorting things first. Not only it saves time… its cool! 😀
(Lets get started…. )
The example i’m gonna show below is for CakePHP.
1) Find httpd.conf file (must be somewhere here <E:\Program Files\xampp\apache\conf\httpd.conf> or whereever you have installed APACHE)
Find this line,
1 |
#LoadModule rewrite_module modules/mod_rewrite.so |
and change to,
1 |
LoadModule rewrite_module modules/mod_rewrite.so |
(just removed the comment, i.e ‘#’)
2) Add a new file say, ‘myconfig.conf’ in <E:\Program Files\xampp\apache\conf\proj\myconfig.conf>
(lets keep the config seperate, so you can modify easily)
3) Add the below lines in ‘myconfig.conf’
1 2 3 4 5 6 7 8 9 10 11 12 13 |
alias /myproj "E:/Program Files/xampp/htdocs/blah/trunk/myproj/app/webroot" <Directory "E:/Program Files/xampp/htdocs/blah/trunk/myproj/app/webroot"> Options Indexes FollowSymLinks MultiViews ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> |
4) Now, in httpd.conf, add the below line
1 |
Include conf/proj/myconfig.conf |
5) Thats it, restart apache and hit <http://localhost/myproj>, it works!!!! but.. its not over it
6) (This is the step which got my nerve) You see the links (any link on those myproj) looks in unshorten form
Open, <E:/Program Files/xampp/htdocs/blah/trunk/myproj/app/webroot/.htaccess>, it should be like below
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /myproj RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] </IfModule> |
Thats all!!! 🙂
For reference, check it out:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase
If you’re stuck with mod-rewrite, check: http://www.lancelhoff.com/enabling-htaccess-in-apache-on-windows/
Checkout more about Sublime Text2 here!