Redirect any subdirectory to another subdirectory using htaccess in wordpress

In our blog sometimes for SEO purpose we need to rename the folder name from one directory to another directory suppose we need to rename my folder name style to trends.we need to redirect all url related to https://www.tutorialshore.com/style/***** to https://www.tutorialshore.com/trends/*****.This can be done by using htaccess redirection .here am going to do in wordpress

RewriteRule ^style/(.*)$ /trends/$1 [R=301,NC,L]
#Here all style folder redirect to trends

Full .htaccess files in wordpress


RewriteEngine On
RewriteRule ^style/(.*)$ /trends/$1 [R=301,NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]  


how can I create my own blog?

Creating your own blog is easy as making instant noodles,like maggi packet everything is available in one packet that is called CMS(content management system),by using any of the content management system you can start your own blog in couple of minutes.one of the most famous CMS is WordPress,millions of blogs are already developed using this simple system. Here am going to discuss with how to develop your own blog with WordPress

see steps

1) Buy your own domain name and hosting space from any of the hosting service provider like go daddy,dont forget to compare the pricing

e.g example.com

2) Download WordPress from the site wordpress.org/download/

3) upload downloaded WordPress archive to the hosting space,that you bought from any of the hosting provider .every hosting provider will give cpanel login.you can use those credential to upload file to root folder

create my own blog

4) Unzip uploaded WordPress files and move the files into root folder

5) Using cpanel GO to MySQL database area

go to phpmyadmin

6) create a new MySQL database name and username

 

MySQL databse

7) Open any browser type example.com

8) fill database info and user info

9) create admin username and password move forward

10) Now visit example.com your own website is live now

cheer 🙂

How to create a new post type in WordPress

To create a new post type in WordPress open function.php file from current active folder
add below code and update

function custom_post_type() {
 
// Set UI labels for Custom Post Type
    $labels = array(
        'name'                => _x( 'Resources', 'Post Type General Name', 'twentythirteen' ),
        'singular_name'       => _x( 'Resources', 'Post Type Singular Name', 'twentythirteen' ),
        'menu_name'           => __( 'Resources', 'twentythirteen' ),
        'parent_item_colon'   => __( 'Parent Resources', 'twentythirteen' ),
        'all_items'           => __( 'All Resources', 'twentythirteen' ),
        'view_item'           => __( 'View Resource', 'twentythirteen' ),
        'add_new_item'        => __( 'Add New Resource', 'twentythirteen' ),
        'add_new'             => __( 'Add New', 'twentythirteen' ),
        'edit_item'           => __( 'Edit Resources', 'twentythirteen' ),
        'update_item'         => __( 'Update Resources', 'twentythirteen' ),
        'search_items'        => __( 'Search Resources', 'twentythirteen' ),
        'not_found'           => __( 'Not Found', 'twentythirteen' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'twentythirteen' ),
    );
     
// Set other options for Custom Post Type
     
    $args = array(
        'label'               => __( 'Resources', 'twentythirteen' ),
        'description'         => __( 'Resources info', 'twentythirteen' ),
        'labels'              => $labels,
        // Features this CPT supports in Post Editor
        'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
        // You can associate this CPT with a taxonomy or custom taxonomy. 
   
     
        'rewrite' => array('slug' => '%types%'),
      //  'rewrite' => false,
      //     'taxonomies'          => array('topics', 'types', 'industry' ),

        /* A hierarchical CPT is like Pages and can have
        * Parent and child items. A non-hierarchical CPT
        * is like Posts.
        */ 
        'hierarchical'        => true,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'post',
    );
     
    // Registering your Custom Post Type
    register_post_type( 'resources', $args );
 
}

 
add_action( 'init', 'custom_post_type', 0 );

It will create a Resources menu in your admin side their you can view or update custom post Resources

How to add auto redirect to https in wordpress

TO add add auto redirect to https in WordPress.

Open .htaccess files from home directory

add below code and upload

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

It look like like full htaccess

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# END WordPress

It will do auto redirect to https in wordpress