I am using Slim framework to build a website. How to I re-write the url using .htaccess ?
This is what my .htaccess file looks like, any route is redirected to index page, I got this from the Slim Documentation
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
This is my directory structure.
|--app
|--bootstrap
|--public
|--css
|--js
|--index.php
|--.htaccess
|--routes
|--vendor
|--views
|--composer.json
|--composer.lock
This how it works now
http://localhost/SlimApplication/public/ - points to the index page http://localhost/SlimApplication/public/Users - points to the users page
This is how I want it to work
http://localhost/SlimApplication/ - should point to the index page http://localhost/SlimApplication/Users - should point to the users page
What can I do to make this work ?? I am new at .htaccess and Slim as well so any help would be great. Thanks, Cheers !
Create new .htaccess file in level up folder hierarchy (the same as public folder). RewriteBase /public/ directive is what you need.
RewriteEngine On
RewriteBase /public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.