How to remove public/index.php/ from url - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: How to remove public/index.php/ from url (/showthread.php?tid=69823) Pages:
1
2
|
How to remove public/index.php/ from url - ktmonty - 01-22-2018 I want normal URL like www.sample.com/controller not www.sample.com/public/index.php/controller. .htaccess :- RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ public/index.php/$1 [L] RE: How to remove public/index.php/ from url - ciadmin - 01-22-2018 https://bcit-ci.github.io/CodeIgniter4/general/urls.html#removing-the-index-php-file If xxx/controller doesn't work, but xxx/index.php/controller does, then your htaccess is not working. Could be rewrite_module not loaded, or wrong permissions. If xxx/controller doesn't work, but xxx/public/controller does, then your document root is set incorrectly inside apache. If you have to resort to xxx/public/anything, then your document root is set incorrectly! RE: How to remove public/index.php/ from url - marin63 - 01-22-2018 I am having the same issue, i added the rewrite rule from the codeigniter guide and set my rewritebase but i am having the is "You don't have permission to access /http://localhost/exercism/apptest/public/index.php/home/sayhi on this server." RE: How to remove public/index.php/ from url - XtreemDeveloper - 01-22-2018 Firstly replace this line in config.php file $config['index_page'] = ''; After that you can update htaccess file by this code RewriteEngine On RewriteBase /project_folder_name/ #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 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] If you are not using htaccess file then make a .htaccess file in root RE: How to remove public/index.php/ from url - ciadmin - 01-22-2018 (01-22-2018, 04:45 AM)marin63 Wrote: I am having the same issue, i added the rewrite rule from the codeigniter guide and set my rewritebase but i am having the is "You don't have permission to access /http://localhost/exercism/apptest/public/index.php/home/sayhi on this server." 1) Your document root is not set properly - it should map to the public folder of your project. 2) Your permissions are not correct - right from the error message you report. RE: How to remove public/index.php/ from url - ktmonty - 01-22-2018 Thanks for reply everyone i tried same as the document but it still not working for this url Code: http://localhost:8080/codeIgniter4/ "If you see this message, you have not configured your web server properly. You need to set your "document root" to the public folder inside your project. This could be your default setting, or that of a virtual host, depending on how you set up your local development environment." working good with Code: http://localhost:8080/codeIgniter4/public/ if i call Code: http://localhost:8080/codeIgniter4/public/home Code: http://localhost:8080/dashboard/ and Code: http://localhost:8080/codeIgniter4/public/index.php/home but i want Code: http://localhost:8080/codeIgniter4/home RE: How to remove public/index.php/ from url - ciadmin - 01-23-2018 It is not supposed to work for "http://localhost:8080/codeIgniter4/" - that's why the error message. You need to set your "document root" to the public folder inside your project. <-- it told you this Once fixed, you would access your project as "http://localhost:8080" or as "http://project.local:8080" if using a virtual host entry for "project.local" (which is my preference). RE: How to remove public/index.php/ from url - ciadmin - 01-23-2018 Once that is fixed, on to the next problem Assuming you have a Home controller, with an index() method, then project.local:8080/home should invoke it. If Home is the default controller, then project.local:8080 would be enough to invoke its index() method. If project.local:8080/home gives a 404, then your rewrite is not enabled, and that needs to be fixed inside Apache config. RE: How to remove public/index.php/ from url - marin63 - 01-23-2018 Thanks everyone for your support, i have been able to fix mine by setting my document root to the public directory. RE: How to remove public/index.php/ from url - InsiteFX - 01-23-2018 If your on a Windows system it will not work the first time for some reason. If you take and delete the index.php off of the url it will then work. Or you need to use a 301 redirect to force it. |