• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to remove public/index.php/ from url

#1
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]
Reply

#2
https://bcit-ci.github.io/CodeIgniter4/g...x-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!
Reply

#3
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."
Reply

#4
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
Reply

#5
(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.
Reply

#6
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/
this url

if i call
Code:
http://localhost:8080/codeIgniter4/public/home
 this url it directly redirects to
Code:
http://localhost:8080/dashboard/



and
Code:
http://localhost:8080/codeIgniter4/public/index.php/home
this works good

but i want
Code:
http://localhost:8080/codeIgniter4/home
to work on this link it shows 404 error
Reply

#7
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).
Reply

#8
Once that is fixed, on to the next problem Undecided

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.
Reply

#9
Thanks everyone for your support, i have been able to fix mine by setting my document root to the public directory.
Reply

#10
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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.