Search code examples
phpapache.htaccesslamp

start URL rewriting in current folder


I have a website in a subdirectory of my domain (example.com/folder)

In this folder I have a .htaccess with this code

RewriteEngine On 
RewriteRule . index.php

When I do a request to this http://www.example.com/folder/example/request my $_SERVER['REQUEST_URI'] is set to /folder/example/request.

How can I force apache to not put the /folder/ into the request_uri-variable.


Solution

  • Since you're dealing with $_SERVER['REQUEST_URI'] you're already in PHP. Why not just strip /folder off if it's there?

    Don't modify $_SERVER['REQUEST_URI'] directly by the way, copy it, modify it, and pass it along to whatever function needs it.

    PHP is much better at manipulating strings than Apache.