I'm having difficulty getting a successful redirect or server
configuration in order to redirect to a nonexistent directory, and
serve the Slim app as though it were actually installed in that
nonexistent directory.

Here are a few example URLs, which I'd like to be able to use in
the browser's location bar, or link to in documents or apps.

When I enter http://example.com/nonexistent_dir in
the location bar, I'm redirected to the / route in
Slim. However, adding any additional routes (e.g.,
http://example.com/nonexistent_dir/info) results in me
getting a No input file specified. message.

My server is apache, with mod_rewrite enabled, in a shared
hosting environment. If anyone can offer some tips to getting this
routing sorted out, it would be greatly appreciated. Thanks!

What is your document_root currently set to? I presume it is the directory you describe as root in your directory structure description?

If you create your index.php file in the root directory and run your slim app from there, the actual directory structure is irrelevant at that point as slim takes over the routing at the application level as apache routes everything through index.php due to your htaccess file.

Also, it's not a good idea to use the structure you describe as the slim library and your application code will be publicly accessible.

I'm not sure what the danger is in having the app code accessible (despite not being referenced by any links, I understand that it's in the "public" area of the site). Database access credentials are stored in a Wordpress database table, so they aren't in the app folders. Seeing the app code will let the curious know that I am in fact accessing a database, but so far as I understand it won't be a security risk.

I can relocate the app code to an area above the web root, but that still doesn't address the desire to point to index.php in a subdirectory. Unfortunately, it sounds like this is beyond the scope of the support you can offer. I'll keep at it in other venues. Thanks for your time.

I may not have been clear. When I use the phrase `nonexistent_dir`, I'm referring to a consistent URL, which will always appear in the location bar as `http://example.com/nonexistent_dir`. The value of nonexistent_dir will not change depending on the incoming request, nor will the fact that I'm trying to redirect it and all subsequent route information to `http://example.com/content/plugins/myplugin/index.php` (while still preserving any additional routing info).

ah - I see, you can do this within slim. you can add a hook before the router matches the route which removed the directory name from the path_info in the request. The router will then match the route based on the remaining "anything_else" in the path_info. You can then use another hook after the router has matched to add the directory name back onto the start of the path_info. This means that the urlFor() function in Slim will build urls for your links with the correct url structure.

That sounds like it's just what I'm looking for. So I'll take a look at the docs for the urlFor() function. If you're aware of anything relevant that might assist me in my research, I'll welcome links to the info. Thanks for your help, Tony.

There is an existing website in place, which has many pages of information and an established directory structure. It's not an option to put the Slim app at `example.com/index.php`. But, rather than requiring `example.com/content/plugins/myplugin/index.php`, I'd prefer to allow `example.com/nonexistent_dir`.

Reading the docs on urlFor(), it looks like this is not quite what I need. As I understand it, urlFor() allows one to take a named route and output the corresponding url. If I have a functioning, named `/info/details` route (named "details"), and I want to generate a link to it, I can use urlFor() to output the url that will take me there. So long as the name remains the "details", even if the actual route becomes `/info/about/details`, when I request the url for the details page, I can use urlFor() and arrive in the proper location.

My problem occurs before getting to this point. I'm only hitting the `/` route. Every other route results in a `No input file specified.` message.

I believe that my problem lies more with the configuration of the apache server than with any shortcoming of the Slim framework. I was just hoping that someone here had encountered a similar challenge and could share their knowledge. While I welcome continued assistance with this challenge, I appreciate that it's probably outside of the scope of your interest, Tony. I will continue to seek answers elsewhere, and if I'm unable to find one I'll change my goals.

Hi, infact I ran into the exact problem. Still I am unable to
find any answer. Its simply ignoring the trailer part. Also, I
found out that if you give a trailer something as /abc.xyz , it
routes to 404 error. bdw, my rewite is this
`
RewriteEngine On
RewriteBase /AppName/