Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subfolder issue #13

Closed
tleb opened this issue Apr 13, 2015 · 7 comments
Closed

subfolder issue #13

tleb opened this issue Apr 13, 2015 · 7 comments

Comments

@tleb
Copy link
Contributor

tleb commented Apr 13, 2015

I am having problems using bramus/router in a subfolder, I do not know if it is coming from me or a class problem:

$ mkdir router-test
$ cd router-test
$ composer require bramus/router
$ touch .htaccess
$ mkdir folder
$ touch folder/.htaccess
$ touch index.php

.htaccess:

RewriteEngine On
RewriteRule ^(.*)$ folder/$1 [L]

folder/.htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

folder/index.php:

<?php

require '../vendor/autoload.php';

$router = new \Bramus\Router\Router;

$router->get('/about', function() {
    echo 'about page';
});

$router->run();

If I call domain.com/path/to/router-test/about, nothing happens.

@tleb
Copy link
Contributor Author

tleb commented Apr 16, 2015

Ok, I found the issue. The class does not support the above case (script in folder while request is made from above folder). I am looking at what could be done to the class to improve this.

(The entire problem comes from getCurrentUri().)

@tleb
Copy link
Contributor Author

tleb commented Apr 16, 2015

A comment line 332 says allows one to run the router in a subfolder. This is false. 👅

@bramus
Copy link
Owner

bramus commented Apr 16, 2015

Hi tleb,

The script does work fine in a subfolder, as long as the .htaccess and and index.php file are in the same folder.

I guess you'll have to fiddle around with RewriteBase in your .htaccess to get it working.

Regards,
Bramus.

@tleb
Copy link
Contributor Author

tleb commented Apr 16, 2015

@bramus I don't really see how RewriteBase can help me. What should I modify in the above files to make it work?

@bramus
Copy link
Owner

bramus commented Apr 16, 2015

Place your index.php and .htaccess in the same folder

@tleb
Copy link
Contributor Author

tleb commented Apr 16, 2015

My current configuration allows me to let users access files in the folder (would be the public/ folder in most framework), this is why I have my files in this configuration.

Could you look at #14 to allow me to adapt the class to my set-up?

@bramus
Copy link
Owner

bramus commented Apr 17, 2015

Merged #14. Closing this one.

@bramus bramus closed this as completed Apr 17, 2015
@ghost ghost mentioned this issue Jul 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants