I am using revolution slider in my Laravel website.When i removed the "/public" from the url using a .htaccess file in my root folder with this code:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
The slider is not loading correctly anymore(no slider shown)
This is the html code:
<div class="topslider" style="margin-top: 80px;">
<div id="slider">
<div class="fullwidthbanner-container">
<div id="revolution-slider">
<ul>
#foreach($sliders as $slider)
#if($slider->type == 'video' && $slider->video && File::exists($slider->video))
<li {{-- data-transition="fade" data-slotamount="7" data-masterspeed="5000" --}}>
<video poster="" id="bgvid" playsinline="" autoplay="" muted="" loop="">
<source src="{{ asset($slider->video)}}" alt="" type="video/mp4">
</video>
{{-- <video src="{{ asset($slider->video)}}" type="video/mp4" playsinline autoplay muted loop> </video> --}}
</li>
#endif
#endforeach
</ul>
</div>
</div>
<div class="tp-bullets">
<div class="simplebullets round bullet">
</div>
</div>
</div>
</div>
And finally this my website url
I get this error in my console:"Uncaught TypeError: Cannot read property 'nextElementSibling' of null"
The standard .htaccess which comes with Laravel 5.4 is
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Try to replace your .htaccess file in public/.htaccess with this contents.
Content copied from https://github.com/laravel/laravel/blob/5.4/public/.htaccess
Related
I am getting this error when uploading a pdf file, any ideas?:
RuntimeException stream_socket_sendto(): A request to send or receive
data was disallowed because the socket is not connected and (when
sending on a datagram socket using a sendto call) no address was
supplied
form in view:
<form action="{{ route('press-files.store') }}" method="POST" enctype="multipart/form-data">
#csrf
<input type="file" name="pressFiles[]" multiple="multiple">
<button type="submit" class="btn btn-primary start">
<i class="pe-upload"></i>
<span>Start upload</span>
</form>
Controller:
public function store(Request $request)
{
$press_files = $request->all();
dd($press_files);
}
this is only happening on .pdf files - png's and jpegs all work.
Thanks for any help in advance
Add these lines in your .htaccess
php_value upload_max_filesize 30M
php_value post_max_size 30M
php_value max_execution_time 300
php_value max_input_time 300
It turned out to be due to file size. I will keep this question and answer incase anybody else requires it.
The .pdf I was using was 2.8 MB and this failed, I used a much smaller file ~125kb and this worked fine.
I installed laravel 5.6 and pasted everything on server Digital Ocean. Now Laravel.Log file not updating anything. Is there any step should I take to solved this?
.env file:
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:S2IOFJ8ruj9fUV5qhOWs7+A48DrIM1bIA9yZ83HbRfQ=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=mysql
DB_USERNAME=root
DB_PASSWORD=*****
BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
You can use a custom log in your main controller. Or return a normal string instead of view.
Log::info("test");
return "test";
If nothing changed, there is another problems.
Web Server
PHP fpm
Any OS problem
Correct configurations for a Laravel project :
Apache
<VirtualHost **IP**:80>
ServerName yourtradelog.com
ServerAlias www.yourtradelog.com
ServerAdmin info#yourtradelog.com
DocumentRoot /home/user/public_html/yourtradelog/public
UseCanonicalName Off
ScriptAlias /cgi-bin/ /home/user/public_html/cgi-bin/
<IfModule mod_userdir.c>
UserDir disabled
UserDir enabled user
</IfModule>
<IfModule mod_suexec.c>
SuexecUserGroup user user
</IfModule>
<IfModule mod_suphp.c>
suPHP_UserGroup user user
suPHP_ConfigPath /home/user
</IfModule>
<Directory "/home/user/public_html">
AllowOverride All
</Directory>
</VirtualHost>
Nginx
server {
listen 80;
server_name yourtradelog.com;
root "/home/user/public_html/yourtradelog/public";
index index.php index.html index.htm;
charset utf-8;
access_log off;
error_log /var/log/nginx/laravel.log error;
sendfile off;
client_max_body_size 100m;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico {
access_log off;
log_not_found off;
}
location /robots.txt {
access_log off;
log_not_found off;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffers 4 16k;
fastcgi_buffer_size 16k;
fastcgi_connect_timeout 300;
}
location ~ /\.ht {
deny all;
}
}
my view is :-
<li class="">
<a class="" href="<?php echo base_url(); ?>Login">
<i class="fa fa-unlock-alt"></i> Login </a>
</li>
my Login Controler
class Login extends CI_Controller {
public function __construct(){
parent::__construct();
}
public function index()
{
$this->load->view('login');
}
}
When i clicked on link it says 404 page not found.
but when edit the link manually and write /index.php/Login it is working fine. how to fix this...
You have to use 3 more steps:
create a .htaccess file on project root(on your project folder "/project" or domain root directory)
Insert following line of codes on .htaccess file.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Find config/congig.php file and change this line to-
*add base url in my case:
$config['base_url'] = 'http://localhost/cirest.dev/'; ( assign your project path/URL)
$config['index_page'] = 'index.php'; to $config['index_page'] = '';
ADD this HTML to your view:
<li>
<a href="<?php echo base_url('login'); ?>">
<i class="fa fa-unlock-alt"></i> Login </a>
</li>
I think it will work. :)
Try site_url() in place of base_url()
<a class="" href="<?php echo site_url(); ?>Login">
First of all you should properly define url in config/routes.php:
$route['login'] = 'login/index';
And then you can use this route in a template with site_url() function:
<li>
<a href="<?php echo site_url('login'); ?>">
<i class="fa fa-unlock-alt"></i> Login </a>
</li>
I changed from $route['login'] = ['login/index']; to $route['login'] = 'login/index'; in my case.
Create a file in the webroot and name it .htaccess then type this code in it
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>
And in your application/config/config.php file, find this
$config ['index_page'] = '';
hi everyone im new to php frameworks development at all, and i can't make this code run please help me im using xampp
my welcome controller
<?php
class Welcome extends CI_Controller
{
public function index()
{
$this->load->view('home');
}
}
home view
<html>
<head>
<title>CTS - home</title>
<style type="text/css">
.auto-style1 {
text-align: center;
}
</style>
</head>
<body bgcolor="#C0C0C0" style="height: 226px">
<div class="auto-style1" style="height: 118px">
<img alt="" height="126" src="<?php echo $this->config->item('base_url'); ? >/IMG/YUC.png" style="float: left" width="147">
<center><h1 style="height: 39px; width: 696px">Cooperative Training Management System</h1></center>
</div>
<br>
<hr>
<div class="auto-style1">
<a href="<?php echo site_url('') ?>users/login">
<img alt="YUC Employee" height="410" src="<?php echo $this->config- >item('base_url'); ?>/IMG/employee.png" width="139">
</a>
<img alt="trainer" height="410" src="<?php echo $this->config->item('base_url'); ? >/IMG/Trainer.png" width="145">
<a href="<?php echo site_url('') ?>users/login">
<img alt="Student" height="410" src="<?php echo $this->config->item('base_url'); ? >/IMG/student.png" width="129">
</a>
<h3>Employee   ; Trainer   ; Student</h3>
</div>
<hr>
<p align="right">Page generated in <strong>{elapsed_time}</strong> seconds</p>
</body>
</html>
and this is the second controller users
<?php
class Users extends CI_Controller
{
function login()
{
$data['error']=0;
if($_POST){
$this->load->model('user');
$username=$this->input->post('username',ture);
$password=$this->input->post('password',true);
$user=$this->user->login($username,$password);
if(!$user){
$data['error']=1;
}else{
$this->session->set_userdata('userID',$user['userID']);
redirect(base_url().'home');
}
}
$this->load->view('login');
}
function logout()
{
$this->session->sess_destory();
redirect(base_url().'home');
}
}
and this is the model user
<?php
class User extends CI_Model
{
function __construct()
{
parent::__construct();
$this->load->helper('url');
}
function login($username,$password)
{
$where=array(
'username'=>$username,
'password'=>sha1($password)
);
$this->db->select()->from('s_users')->where($where);
$querh=$this->db->get();
return $querh->first_row('array');
}
}
and this is the login view
<html>
<head>
<title>CTS - Login</title>
<style type="text/css">
.auto-style1 {
text-align: center;
}
</style>
</head>
<body bgcolor="#C0C0C0" style="height: 98px">
<div class="auto-style1" style="height: 118px">
<img alt="" height="126" src="YUC.png" style="float: left" width="147">
<center><h1 style="height: 113px; width: 696px">Cooperative Training Management System</h1></center>
</div>
<br>
<hr>
<div class="auto-style1">
<fieldset name="Group1">
<legend align="left"><h1>Login</h1></legend>
<?php if($error==1){ ?>
<p>Your Username / Password did not match.</p>
<? } ?>
<form action="<?=base_url()?>users/login" method="post" style="height: 96px">
<label>Username </label><input name="Text1" type="text">
<br>
<label>Password</label> <input name="Password1" type="password">
<br><br>
<input name="Login" style="width: 96px" type="submit" value="Login">
</form>
</fieldset>
</div>
<hr>
<p align="right">Page generated in <strong>{elapsed_time}</strong> seconds</p>
</body>
</html>
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#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 see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
Maybe url is incorrect.
http://localhost/projectfolder/index.php/controller/method
in ur case:
http://localhost/yourprojectfolder/index.php/users/login
Replace "projectfolder", "controller", "method" with yours. Make sure your file name for Users Controller is "users.php"
use
base_url();
instead of
$this->config->item('base_url');
if you want to keep a config param use this :
$this->config->config['base_url'];
also this is not ok:
<?php echo site_url('') ?>users/login
use it like this:
<?php echo site_url('users/login') ?>
In the end check if you have views/home.php file
can't see anyother error in your code
then be sure you have:
$config['index_page'] = '';
and use this htaccess:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
If you Using WAMP server then open "httpd.conf" file, search "LoadModule rewrite_module modules/mod_rewrite.so" and remove # which in the start of the same line..
and restart your WAMP Server
Then add this code to your .htaccess file which is in the codeigniter folder (if not create it in the folder's root):
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
check for URL which call functions
for e.g
Correct URL
http://127.0.0.1/mysites/site1_ci_bootstrap/index.php/welcome/home
May be your URL is
http://127.0.0.1/mysites/site1_ci_bootstrap/welcome/home
NOTE : Initially always need to mention "index.php" into the path which redirect to main class "welcome", To remove "index.php" put .htaccess script into root folder, google several htaccess script you find one.
I have no idea what I'm doing wrong with ModRewrite. rewrite.load and proxy.load have been loaded with a2enmod and both appear under modules enabled. I tried to set up the most basic ModRewrite scenario I could think of but it doesn't redirect at all, I still get the same 404 error messages had they not even been enabled.
Here's what my directory looks like
/var/www
/test
showimage.php //showimage.jpg should redirect here
test.html //a page with a <img> tag that points to showimage.jpg
.htaccess //I've tried putting this in /var/www but it doesn't work either
Here's my .htaccess
Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteBase /var/www/test
RewriteRule ^showimage.jpg?(.*) http://localhost/test/showimage.php?$1
RewriteRule ^test.jpg http://localhost/test/showimage.php
Here's test.html
<html>
<body>
<img alt="didn't work" src="showimage.jpg?thing=thing1" />
</body>
</html>
Here's showimage.php
<?php
header('Content-Type: image/jpeg');
$im = imagecreatetruecolor(400, 30);
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
if(isset($_GET["thing"])) {
$text = $_GET["thing"];
}
else {
$text = "none set by GET params";
}
$font = "some.ttf";
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
imagejpeg($im);
imagedestroy($im);
?>
Finally, here's my only currently enabled site on apache:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Does anybody know why this setup for a modrewrite isn't working?
You have AllowOverride None in all relevant directories. I believe you need AllowOverride FileInfo Options (at a minimum) for the relevant directory, which in this case appears to be /var/www.
Edit:
In case it wasn't clear, I'm referring to your virtual host configuration, not anything in .htaccess.
change AllowOverride None in AllowOverride All and restart your server.