Let’s say you have a new web project you’re working on. Sure, you could setup a web server on your local machine and develop locally. For some reason you don’t want to do that though. Anyway, with this setup we’re going to assume you have some kind of landing page at the URL – why not? And you have a development directory `dev`. Now, as things get more complicated with this project, it would be nice if you could just point your browser at the root of the domain instead of a development directory. After all, eventually that’s where it’s going to live. Luckily, the solutions lies in `.htaccess`.
RewriteEngine on
RewriteCond %{REMOTE_ADDR} ^12.345.678.90
RewriteRule (.*) /dev/$1 [P,L]
Assuming your IP address is 12.345.678.90, this will forward the root of the domain to the /dev/ directory and your browser won’t know the difference. P means this is a proxy, so the URL won’t change. R would be a redirect which reloads the page at the URL – `/dev/` in this case.
Since anyone could potentially spoof their `REMOTE_ADDR`, security is up to you.
**Note:** You’ll need mod_rewrite for apache installed for this to work.