Professional Documents
Culture Documents
WordPress Codes
WordPress Codes
Permalink Code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
==================================================================
==================================================================
define('WP_DEBUG', true);
===================================================================
==================================================================
# Images
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType imindage/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# Video
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
# CSS, JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
# Others
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
===================================================================
OR
Add below code in wp-config.php WP Dashboard cookie error
define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');
===================================================================
Code to deny a specific file (ex: config.php):
<Files config.php>
order allow,deny
Deny from all
</Files>
==================================================================
How to comment a deny code:
#<Files config.php>
#order allow,deny
#Deny from all
#</Files>
===================================================================
Example: http://wprt.nhtipage.com/wp-admin/maint/repair.php
Just don’t forget to remove the line WP_ALLOW_REPAIR from wp-
config.php when you’re done.
=======================================================
For older PHP versions, The SQL adapter or the DB type was mysql. However for PHP 7.2 and
above we need to change it to mysqli. So changing it to mysqli will fix most of the broken PHP
websites depending on which website builder has been used.
mysql_connect() does not work on newer versions of PHP. Confirm the
PHP version set in the account and take permission from the
customer to switch it to an older version of PHP say 5.3/5.5/5.6.
=========================================================
Htaccess Codes: https://www.htaccessredirect.net/
Test script to test database connection. Create file dbtest.php and add
below code
Note: Make sure to replace the localhost with database hostname,
username with db username and password with database password
<?php
$servername = "localhost";
$username = "username";
$password = "password";
c // Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
==========================================================
To resolve Mixed Content issue with SSL : add it in the .htaccess file
Header always set Content-Security-Policy: upgrade-insecure-requests
==========================================================
Redirect http to https: add it in the .htaccess file (301)
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
==========================================================
phpinfo Code: create a new file with name phpinfo.php
<?php
phpinfo();
?>
==========================================================
http://saravanapriya14058.ipage.com/sessiontest.php
Testing session path. Create a file sessiontest.php and add below code
<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
if(!$_SESSION['count']){
$_SESSION['count'] = 1;
} else {
$_SESSION['count']++;
}
echo $_SESSION['count'];
?>
======================================================
post_max_size = 50M
==========================================================
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but
loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.
*
* @var bool
*/
define('WP_USE_THEMES', true);
==========================================================
Automatic WordPress Updates Disabling:
Add below code in the wp-config.php file:
define( 'WP_AUTO_UPDATE_CORE', false );