Good morning,
For the information and comments made, I think the topic is based on the suggestion you made Juan Pinzón :
Are you placing pure php in the same root directory of your project in codeigniter ??
As a general rule, Frameworks are usually designed to redirect all traffic towards index.php
of the root of the application with the help of .htaccess
. And any other url that is not in the router configuration resolves it as a error 404
.
The simplest way ( personal opinion ) to manage multiple projects is to use virtual hosts
. You can find information about the different configurations and how to adapt it to your needs. But basically it's about creating a virtual host
on your Ubuntu machine, and configuring the file hosts
on the client machine, either the Ubuntu itself or if you have it mounted on a Virtual Machine, then on the Client Machine.
The configuration that I have is Mac and Ubuntu Virtual Machine that I will give example.
Create a project, phptest.web for example
1 .- Create a root directory for the project
sudo mkdir /var/www/phptest
Grant permissions
sudo chown -R $USER:$USER /var/www/phptest
sudo chmod -R 755 /var/www
2 .- Create a file% test_co%, php
within the root directory of the new index.php
.
/var/www/phptest/index.php
<?php echo 'run!'; ?>
3 .- Create the file of virtual host
phptest.web for example:
The file is called virtual host
And it's saved on the route phptest.conf
<VirtualHost *:80>
ServerName phptest.web
ServerAlias www.phptest.web
ServerAdmin webmaster@localhost
DocumentRoot /var/www/phptest
<Directory /var/www/phptest>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
4 .- Activate the virtual host
sudo a2ensite phptest.conf
5 .- Restart apache
sudo service apache2 restart
6 .- Edit the file /etc/apache2/sites-available/
On Ubuntu or Mac, you can find that file at: hosts
You open it and at the end of the file you set the new /etc/hosts
I have put the ip of the virtual machine as an example. You just have to change it to the server.
192.168.1.2 phptest.web www.phptest.web
7 .- Test if it works
You open the browser and go to: host
Logically you will have to configure everything with the data and under the structure you have to function. If I have not skipped any step, that sequence should let you have several projects, frameworks or php files running independently without affecting the configurations of http://www.phptest.web/
of projects you have.
I hope it works.
Greetings,
PS .: If you find an error, comment and edit it.