Site move for 1 server to new developed server LEMP
Getting error 403 Forbidden nginx/1.14.0 (Ubuntu) apt
- 0 like
- 1 comment
Dhananjay Kumar |19 May at 09:05
Site move for 1 server to new developed server LEMP
Getting error 403 Forbidden nginx/1.14.0 (Ubuntu) apt
Dhananjay Kumar19 May at 09:05
We have reviewed and seems file directory permission is changed and seems below Error:
"/var/www/domain.com/xyz.php" failed (13: Permission denied), client: xx.xxx.xx.xx
Finally used below command :
sudo chown -R www-data:www-data /var/www/*
sudo chmod -R 0755 /var/www/*
and restart nginx : sudo service nginx restart
and all working fine
Rajnish Kumar |07 Aug at 05:08
Hi anyone's,
I want to implement 301 redirection http both version, index.php and https non www version to https www version.
Please suggest me!!
Regards
Rajnish
Dhananjay Kumar10 Jan at 05:01
Hi,
Please try the below script , its work on all :
For www only :
if ($_SERVER['HTTP_HOST']=='xyz.com') {
$url = "http://www.". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header( "HTTP/1.1 301 Moved Permanently" );
header("Location: {$url}");
exit;
}
With HTTPS & WWW :
if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on" || $_SERVER['HTTP_HOST']=='domainname.com') {
$url = "https://www.". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header( "HTTP/1.1 301 Moved Permanently" );
header("Location: {$url}");
exit;
}
Try and suggest.
Mukund verma |08 Sep at 11:09
Hello i want a solutions for categories off subcategories in array n level .
Sanjana Kumari08 Sep at 12:09
<?php
$hostname = "localhost";
$db_username = "root";
$db_password = "";
$db_name = "test";
$db = new mysqli($hostname, $db_username, $db_password, $db_name);
class categoryss {
public function get_categories($id){
global $db;
$querycat='';
$gcategories=array();
if(is_null($id)){
$querycat = "SELECT cat_id,cat_name,parent_id FROM categories WHERE parent_id='0'";
}else{
$querycat = "SELECT cat_id,cat_name,parent_id FROM categories WHERE parent_id='".$id."'";
}
$result = $db->query($querycat);
if($result->num_rows>0){
while($row=$result->fetch_assoc()){
if(!empty($row['cat_id']) && $row!=''){
$gcategories[]=$row;
if(!empty($this->get_categories($row['cat_id']))){
$gcategories[]['child']=$this->get_categories($row['cat_id']);
}
}
}
}
return $gcategories;
}
////////////////////////////////////////
}
$obj=new categoryss();
$getNlevelCategory=$obj->get_categories('0');
/*echo "<pre>";
print_r($getNlevelCategory);*/
function traverseArray($array) {
if(is_array($array)){
foreach($array as $vals) {
echo @$vals['cat_name'] . "<br>";
traverseArray(@$vals['child']). "\n";
}
}
}
echo traverseArray($getNlevelCategory);
?>
Dhananjay Kumar |13 Aug at 11:08
Behave simply change below In command line and its working fine.
sudo apt-get install php7.0-curl
sudo systemctl restart php7.0-fpm
Please try.
Thanks
Gaurav Thakur |18 Jul at 04:07
Hi all,
I am new to PHP and my project's requirement is to store the data in database through form, submitted by end users, so i need to secure my code from XSS attacks and filter data. Can anyone guide me for the same. I am using Core PHP (OOP's) not any framework.
Thanks in advance :)
Ravinder |26 Jun at 01:06
FILTER_VALIDATE_EMAIL function not working
See below mention example:
$email = "abc@domain.c";
if (filter_var($email, FILTER_VALIDATE_EMAIL))
echo "Email: ".$email." correct";
else
echo "email not correct";
//It returns:
Email: abc@domain.c correct //which is invalid email id
?>
Why FILTER_VALIDATE_EMAIL not work?
Because FILTER_VALIDATE_EMAIL not accepting Internationalized Domain Names and not allowed all characters according to RFC2822, so it might be better to use regex in php to validate email address instead of filter_validate_email.
Email validation in regex in php:
function valid_email($str) {
return (!preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
}
if(!valid_email("abc@domain.c")){
echo "Invalid email address.";
}else{
echo "Valid email address.";
}?>
Singh Atendra |24 May at 01:05
My project's requirement is to integrate codeigniter and wordpress. Codeigniter files are in root directory of wordpress. Everything is working fine in wordpress but when i access the codeigniter pages it redirect me on wordpress's page not found page. My site is running on LEMP server. i searched regarding it on google , there were some solutions so i tried them but nothing worked in my case. Please help. I thank you in advance.
Dhananjay Kumar26 May at 11:05
I was getting the same issues with LEMP server cause there, not .htaccess file working.
Due to this reason Codeigniter files path "https://abc.com/xyz/" is followed WordPress URL.
I have done the following below script in /etc/nginx/sites-enabled/default file:
location /xyz {
try_files $uri $uri/ /xyz/index.php?$args;
}
location /test {
try_files $uri $uri/ /test/index.php?$args;
}
Added above multiple "location" path which using in CodeIgniter. And its working fine for me.
Please once try above, hope you getting the solution.
Veer Sreenivas |24 Apr at 01:04
Hi, I need help to integrate Paytm payment gateway on web and APP.
Can anyone here share step by step process with sample code to do the same.
I am using PHP as backend langauge.
thanks in advance.
Mukund verma |23 Mar at 01:03
Govind Ramchander31 Mar at 07:03
Yes PHP is a single inheritance language
Single inheritance enables a derived class to inherit behavior and properties from a single parent class. It allows a derived class to inherit the properties and behavior of a base class, thus enabling code reusability as well as adding new features to the existing code. This makes the code much more elegant and less repetitive. Inheritance is one of the key features of object-oriented programming (OOP).
Single inheritance is safer than multiple inheritance if it is approached in the right way. It also enables a derived class to call the parent class implementation for a specific method if this method is overridden in the derived class or the parent class constructor.
Dhananjay Kumar |10 Apr at 05:04
I have setup cronjob on nginx server using below command :
$ crontab -e
and adding below script :
00 10 * * * /usr/bin/php /var/www/project_domain.com/index.php xyz_controller cronmethod
Above for the codeigniter function to run.
Not working any suggest.
Dhanavi |07 Apr at 08:04
I am getting issues with the project live this Fatal error: Cannot use string offset as an array in /var/www/html/abc/xyz.php at line 40.
Same script working on my local server. I notice that's my local php version is 5.6 and live server version is 5.3.
Any have idea about this.
Dhanavi |22 Mar at 08:03
I am getting this error while integrating facebook login funcationality with php in my web.
please help.
Gurnam Hiranandani |05 Apr at 07:04
I am newbie to PHP, can anyone explain me Getter and Setter methods in PHP, are they work similar like in JAVA or there is something different concept PHP use for these.
Govind Ramchander |15 Mar at 12:03
I am facing issues when sharing post on facebook. Facebook is randomly selecting images, title and descripton. I googled and tried some solutions but all those solutions did not work in my case. Those was working perfect for single post page but i have multiple posts listing on a single page.
need help.
Kaustubh Luthra28 Mar at 12:03
try this
<a href="https://www.facebook.com/sharer/sharer.php?u=example.org" target="_blank">
Share on Facebook
</a>
Replace the example.org with your post url.
paste this anchor tag where you want to display facebook share button
or if you have posts listed using loop then paste it within loop. I think it should work.
Govind Ramchander28 Mar at 12:03
Thanks Kaustubh Luthra but it didn't work for me. Random title, description, image are being posting using this solution.
Sandeep Navaneet Saklani28 Mar at 01:03
I faced the same issue with a project of mine. After many days on debugging and searching found a solution which i am sharing with you.
function share_me(url, title) {
u=url;
t=title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),
'sharer',
'toolbar=0,status=0,width=500,height=450');
}
<a href="javascript:void(0);" onclick="share_me(url, title)" target="_blank">
Share on Facebook
</a>
Hope this will help.
Govind Ramchander31 Mar at 01:03
This solution is also not working. I am not getting what i am doing wrong.
Immwit |31 Mar at 06:03
Getting below error with site configure on new nginx server with php7.0
Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime()