mod_rewrite, can't rewrite existing file - .htaccess

I'm trying to pass all images in a directory to watermark.php using mod_rewrite in .htaccess.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule \.jpg$ /watermark.php?path=%{REQUEST_FILENAME} [L]
It works fine on local machine, but on my online production server (shared hosting) all image files are served without rewriting.
mod_rewrite is enabled online, but it ignores the rule if file exists.
What could be wrong?
UPDATE
Here's my full setup: there's a domain with a subdomain in a subfolder of main domain's document_root.
public_html (example.com DOCUMENT_ROOT)/
img (img.example.com DOCUMENT_ROOT)/
.htaccess in public_html folder:
<FilesMatch "\.(inc\.php|log)$">
Deny from all
</FilesMatch>
Options -Indexes +FollowSymLinks
php_value short_open_tag 0
php_value auto_prepend_file /home/username/public_html/bootstrap.inc.php
RewriteEngine On
RewriteCond %{HTTP_HOST} ^img\. [NC]
RewriteRule .* - [L]
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^example\. [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ shop/$1 [L]
.htaccess in img folder:
<FilesMatch "\.(inc|log)$">
Deny from all
</FilesMatch>
Options -Indexes +FollowSymLinks
php_value short_open_tag 0
php_value auto_prepend_file none
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule \.jpg$ /watermark.php?path=%{REQUEST_FILENAME} [L]
The problem is that existing images in img folder are not rewrited. Apache just serve them as is. But if, for example, I request non-existing file the rule works and echo $_GET['path'] prints the full filepath to non-existing file.

Here's what you can use:
RewriteEngine On
RewriteRule ^(media|image|images)(/?)(.*)$ - [F]
RewriteRule ^([a-z0-9\-_\.]+)\.(jpg|jpeg|png|gif)$ /watermark.php?path=%{REQUEST_URI} [L]
The first RewriteRule is set to make sure people don't go to that folder - it gives a 403 permission denied (this is optional)
The second one will redirect any images that match letters, numbers, dash, underscore and dot with the extension: jpg, jpeg, png and gif to your watermark.php file. eg:
http://www.domain.com/logo.jpg => path = /logo.jpg
UPDATE:
Since the rule is in a different folder and the root directory of IMG is /home/username/public_html/img/ the watermark.php file does not exists. Either copy the file you need (watermark.php and its libraries) to the IMG folder or create symblink.
cd /home/username/public_html/img/
ln -s ../watermark.php (and other library files as well)

htaccess change :
Options -Indexes +FollowSymLinks
by
Options -Indexes +FollowSymLinks -MultiViews
This behaviour steel exists on Apache 2.4..

Related

Error installing another PHP app in subfolder of SilverStripe

I have Silverstripe installed on www.mywebsite.com (I made that up just as an example)
I am testing Wordpress on www.mywebsite.com/test
Here is my .htaccess file in my root folder:
### SILVERSTRIPE START ###
# Deny access to templates (but allow from localhost)
< Files *.ss >
Order deny,allow<br>
Deny from all<br>
Allow from 127.0.0.1
< /Files >
# Deny access to IIS configuration
< Files web.config >
Order deny,allow
Deny from all
< /Files >
# Deny access to YAML configuration files which might include sensitive information
< Files ~ "\.ya?ml$">
Order allow,deny
Deny from all
< /Files>
# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
< IfModule mod_env.c>
# Ensure that X-Forwarded-Host is only allowed to determine the request
# hostname for servers ips defined by SS_TRUSTED_PROXY_IPS in your _ss_environment.php
# Note that in a future release this setting will be always on.
SetEnv BlockUntrustedIPs true
< /IfModule>
< IfModule mod_rewrite.c>
# Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
< IfModule mod_dir.c>
DirectoryIndex disabled
< /IfModule>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine Off
# Enable HTTP Basic authentication workaround for PHP running in CGI mode
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Deny access to potentially sensitive files and folders
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
# Process through SilverStripe if no file with the requested name exists.
# Pass through the original path as a query parameter, and retain the existing parameters.
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* framework/main.php?url=%1 [QSA]
# If framework isn't in a subdirectory, rewrite to installer
RewriteCond %{REQUEST_URI} ^(.*)/framework/main.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . %1/install.php? [R,L]
< /IfModule><br>
### SILVERSTRIPE END ###
< IfModule pagespeed_module>
ModPagespeed Off
</IfModule>
< IfModule mod_expires.c><br>
ExpiresActive Off<br>
< /IfModule>
Code on /test/.htaccess:
< IfModule mod_rewrite.c><br>
SetEnv HTTP_MOD_REWRITE On<br>
RewriteEngine On<br>
RewriteBase /<br>
RewriteCond %{REQUEST_URI} !/test<br>
RewriteEngine On<br>
RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteCond %{REQUEST_FILENAME} !-d<br>
RewriteRule . /index.php [L]<br>
< /IfModule>
Any ideas? Note: The < br > does not show up in the actual file and there are no spaces between the < and >
I get a list of all my files. My index.php file doesn't even show up properly and the URL changes from /test to test/?url=/test
I use zoom.ph shared hosting.
Update:
My new code in the root .htacccess file:
RewriteEngine On
# Change any direct URLs (www.unclebubby.com...) to the subdomain (wavs.unclebubby.com)
RewriteCond %{HTTP_HOST} ^(www\.)?collegeconnect\.ph$ [NC]
RewriteCond %{REQUEST_URI} ^/test/(.*)$ [NC]
RewriteRule .* http://test.collegeconnect.ph/%1 [R=301,L]
RewriteCond %{REQUEST_URI} !/test
# If there is a .htm at the end of the URL, get rid of it (due to migration of site from FrontPage)
RewriteCond %{REQUEST_URI} ^/(.+)\.htm$ [NC]
RewriteRule ^.+\.htm$ /%1 [R=301,L]
RewriteBase /
### SILVERSTRIPE START ###
I tested this and what you have seems to work fine. Just ensure you have no errors in your htaccess. You can check apache.log for this.
Here's what I used:
DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/test
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
This redirected me successfully to the Wordpress setup page (fresh install).
First, your RewriteBase in test/.htaccess is wrong. It's not "/" (root), but "/test/" (as files are there).
Second, you have "RewriteEngine On" twice in your test/.htaccess - which may not be an error, but not needed anyway.
Third - your test/.htaccess file is literally disabled by itself by line:
RewriteCond %{REQUEST_URI} !/test
which means - all requests that don't have "test" in URL, which no request to "test" folder can fullfil. Your test/.htaccess should look like this:
< IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
< /IfModule>
BONUS: Silverstripe scans entire folder where it is installed and adds those classes to its manifest, which means you should exclude wordpress (ie folder "test") by placing empty file called "_manifest_exclude" in it.
mention folder name in 'RewriteBase' like below in .htaccess file at your root path
RewriteBase '/SilverStripe/'
where SilverStripe be ur folder name like u mentioned
RewriteBase '/test/'
please do remember to add slash before and after the folder name. If it doesnt work , then let me know. Thanks

How do you redirect all request to public/ folder in laravel 5

I have a classic Larevel 5 project structure and I need to redirect all requests to public/.
I am on a classic hosting environment so public/ is a subfolder of my document root.
I shall imagine it can be done via .htaccess but I still need to figure out how. Anyone can help?
Thanks
There are two solutions:
1. Using .htaccess with mod_rewrite
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
2. You can add a index.php file containing the following code and put it under your root Laravel folder (public_html folder).
<?php
header('Location: public/');
You don't need to change anything in Laravel's default public/.htaccess file.
Just create a new .htaccess in the same level your public folder and add the following content to it:
DirectoryIndex index.php
RewriteEngine On
RewriteRule ^$ public/index.php [L]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
That simple!
This is an extract from another answer which may also help you.
--
Modify your public_html/.htaccess to redirect all requests to the public subfolder.
# public_html/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect All Requests To The Subfolder
RewriteRule ^ /public
</IfModule>
Make sure you have the proper public_html/public/.htaccess (GitHub).
# public_html/public/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization}
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
If you use cPanel, then:
1.Go to folder:
/var/cpanel/userdata/my_domain
2.Edit the both domains:
my.domain and my.domain_SSL
Add to the documentroot section /public:
documentroot: /home/user/public_html/public
3.Rebuild Apache config:
/scripts/rebuildhttpdconf && service httpd restart
if you using apache , add .htaccess file to your root directory with this lines :
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
and make sure your apache redirect and rewrite modules is working fine .
you can use vhost to redirect the all request to your public directory with set public as root of your project .
The ideal scenario is to have /home/user/public as a symlink from /home/user/laravel/public.

.htaccess redirect & hide directory path in url

I have wordpress installed in root directory. I want to use some separate php files as a page on my domain, for which I have made a separate directory which holds all files for serving the php files, of which the directory structure is as:
the root folder has all the wordpress files
the directory which I'd like to serve as a page
/inc/css/
/inc/php/
/inc/img/
the CSS stylesheet files directory location in the PHP file is ../inc/css one step back & then css folder.
I want to hide folders from URL such as the files are served from the root (hide the /inc/php/, /inc/css/ & /inc/img/ folders from URL).
eg: www.domain.com/inc/php/about.php redirect & rewrite this URL to www.domain.com/about
the .htaccess in my root
RewriteEngine On
RewriteBase /
# disable directory browsing
Options -Indexes
# Prevent hotlinking of images htaccesstools.com/hotlink-protection
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif|ico|pdf|flv|jpg|jpeg|mp3|mpg|mp4|mov|wav|wmv|png|gif|swf|css|js)$ - [NC,F,L]
RewriteRule ^login$ http://domain.com/wp-login.php [NC,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<files wp-config.php>
order allow,deny
deny from all
</files>
<files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</files>
I have tried the simple redirect rule but the folders are exposed in the URL.
Redirect 301 /about.php /inc/php/about.php
also I have some more files in the PHP folder on which I'd like to apply the same rule of redirect & rewrite URL & hide folders from URL & remove the PHP extention.
www.domain.com/inc/php/about.php redirect & rewrite this URL to www.domain.com/about
This, of course, means that you can't have the same base filename that's a php file and, say, a css file. Since if the request is www.domain.com/about, is that supposed to map to /inc/php/about.php or /inc/css/about.css? Or is it an image? If you have both files, only one will get mapped to.
But if that's really what you want, try adding these rules right after the hotlinking rule that you have:
# Externally redirect requests for /inc/
RewriteCond %{THE_REQUEST} \ /inc/(php|img|css)/([^\?\ ]+)\.(php|css|jpe?g|png|gif) [NC]
RewriteRule ^ /%2 [L,R=301]
# Check if the request is a php file:
RewriteCond %{DOCUMENT_ROOT}/inc/php%{REQUEST_URI}.php -f
RewriteRule ^(.*)$ /inc/php/$1.php [L]
# Check if the request is a css file:
RewriteCond %{DOCUMENT_ROOT}/inc/css%{REQUEST_URI}.css -f
RewriteRule ^(.*)$ /inc/css/$1.css [L]
# Check if the request is a jpeg file:
RewriteCond %{DOCUMENT_ROOT}/inc/img%{REQUEST_URI}.jpg -f
RewriteRule ^(.*)$ /inc/img/$1.jpg [L]
# Check if the request is a gif file:
RewriteCond %{DOCUMENT_ROOT}/inc/img%{REQUEST_URI}.gif -f
RewriteRule ^(.*)$ /inc/img/$1.gif [L]
# Check if the request is a png file:
RewriteCond %{DOCUMENT_ROOT}/inc/img%{REQUEST_URI}.png -f
RewriteRule ^(.*)$ /inc/img/$1.png [L]

Removing index.php in CodeIgniter using .htaccess file

I'm currently developing a website using CodeIgniter and I recently stumbled upon a routing & .htaccess problem.
Basically, the structure of my simple website (let's call my project 'CIExample' for the sake of simplicity) is as follow:
-Home
-About Us
-Our Service
-News
-Contact Us
which I implemented using a Page controller. This controller has 5 functions which called respective page's view, i.e:
Home(), which calls the view 'Home'
About(), which calls the view 'About Us' and so on..
Previously, to access 'Home', I would need to type http://localhost/CIExample/index.php/page/home into the url window, but after setting the following routes I was able to remove the 'page' (classname) part:
$route['default_controller'] = 'page/home';
$route['home'] = 'page/home';
$route['about'] = 'page/about';
$route['service'] = 'page/service';
$route['news'] = 'page/news';
$route['contact'] = 'page/contact';
However, the tricky part came when I try to remove the 'index.php'.
I want to be able to access the home page by typing http://localhost/CIExample/home.
So I did a lot of searches on CI forum/tutorial/stack overflow, and found some codes for .htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
or http://ellislab.com/forums/viewthread/197675/#929904
I tried both codes but none works..
http://localhost/CIExample/home would direct me to 404 not found page, but http://localhost/CIExample/index.php/home would work just fine.
I wonder what went wrongs? Is it my routes.php or .htaccess or both?
Thanks.
Note: I've also changed my 'config/config.php' file -> $config['index_page'] = '';
EDIT:
Finally it works!
After tweaking the config.php file in config folder and set the following $config['uri_protocol'] = 'PATH_INFO'; (from 'AUTO').
Available Values:
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
Dunno what's the different but according to one of the comments in http://www.jotorres.com/2011/12/removing-index-php-from-url-in-codeigniter/, the same code might/might not work in the production server.
Anyone can explain the reason maybe?
You just need to paste this in your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
and make this alternation to your application/config/config.php file:
$config['index_page'] = '';
I have use following method, it is working perfectly in UBUNTU...!!
First of all verify that you have enabled mod_rewrite (you can verify using phpinfo()) in your index.php file.
IF DISABLED mod_rewrite then RUN:
1. sudo a2enmod rewrite
2. sudo gedit /etc/apache2/sites-available/defaut
just replace "AllowOverride None" to "AllowOverride All" in Tag(<'Directory /var/www/'>)
3. Then please run sudo service apache2 restart
Ok Good...
Now in your root directory of Codeigniter -> Find .htaccess file, if not found then press ctrl+h , still not found then create a file .htaccess
In .htaccess
Paste following code :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ROOT DIRECTORY NAME/
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Ok finally just replace ROOT DIRECTORY NAME
DONT FORGOT TO REMOVE index.php from application/config/config.php file
Make that line like
$config['index_page'] = '';
I use this htaccess for all my CodeIgniter projects. It supports subfolders too.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
In your system/application/config/config.php, Change
$config['index_page'] = "index.php";
To
$config['index_page'] = "";
And in your .htaccess,add this:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|stylesheets|scripts|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
for Codeigniter 3.1.4
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php56” package as the default “PHP” programming language.
<IfModule mime_module>
AddType application/x-httpd-ea-php56 .php .php5 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php5_module>
php_flag asp_tags On
php_flag display_errors On
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 512M
php_value post_max_size 128M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
php_value upload_max_filesize 128M
php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Live:
#RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Local:
#RewriteRule .* index.php/$0 [PT,L]

.htaccess - Subdomains to folders = subfolders 404

Sorry if the title is confusing.
I have set up a virtual host on my local machine. I've set http://dev to map to my /htdocs/dev folder. With some help from dnsmasq and .htaccess, I've set it up so that it maps subdomains of .dev to folders inside /htdocs/dev. And it all works perfect when I try to access, for example, http://dev/file1.html or http://folder.dev/file2.html. The problem occurs with accessing subfolders. I get a 404 Object not found if I try to access http://folder.dev/subfolder/ or http://folder.dev/subfolder/file3.html.
I guess it can be solved with .htaccess, but I failed to do it although I tried. Here's how my /htdocs/dev/.htaccess looks like:
# Default index file
DirectoryIndex index.php
# Interpret .html files as .php scripts
AddHandler php5-script .php .html
# Redirect subdomains to their respective folders
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.dev$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+)\.dev$ [NC]
RewriteRule !^([a-z0-9-]+)($|/) /%2%{REQUEST_URI} [PT,L]
I should mention that, if I try to access http://dev/folder/subfolder/file3.html, there are no problems.
How can I set addresses such as http://folder.dev/subfolder/ point to /htdocs/dev/folder/subfolder?
Try changing your rules to:
RewriteCond %{HTTP_HOST} !^www\.dev$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+)\.dev$ [NC]
RewriteCond %{DOCUMENT_ROOT}/%2{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/%2{REQUEST_URI} -d
RewriteRule ^ /%2%{REQUEST_URI} [PT,L]
First, thanks goes to #JonLin for giving me a hint about this.
I've managed to solve this with this .htaccess file:
# Ordered list of index files, if none exist, show directory listing
DirectoryIndex index.php index.html
# Interpret .html files as .php scripts
AddHandler php5-script .php .html
# Redirect subdirectories to their respective folders
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.dev$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)\.dev(.*)?$ [NC]
RewriteRule !^%2\.dev%3?/$ http://dev/%2%{REQUEST_URI}/ [P]
What Rewrite part of this does is it takes a URL in form of http://folder.dev/subfolder and points it to /dev/folder/subfolder while preserving the URL. It works with or without www.

Resources