Considering you got an Apache server, use this full code in the .htaccess file:
# Block the include-only files.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
</IfModule>
# 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
As a bonus, I would also add this:
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
Related Posts:
- How to show one post different from the rest?
- Display posts side by side with custom query
- active link for most recent post on vertical tabs
- Declare inline background image in functions.php
- Stylesheet won’t load even when linked
- database query with more than a couple meta hangs and doesn’t complete
- Gallery shortcode numerical sorting
- Check return value of get_posts
- How Can I Change The Tax Query For The Main Loop For Taxonomy Archives?
- Query post with meta value in set of values
- get_template_part causes 500 error
- Finding WordPress Posts assigned to multiple categories
- The most effective way to split by post type in custom query?
- Does meta_value (array) work with ‘orderby’?
- Get a list of posts by specific category
- WordPress Query String: get_posts(‘cat=5’) vs WP_Query( ‘cat=5’) vs URL: /site/?cat=5
- WP_Query – Adding “offset” posts to the end of the loop
- Shortcode for custom query not returning results when attributes are added
- wp_query is showing posts from other categories
- Multiple wordpress queries with nested output (odd – even)
- Get posts in taxonomy randomly
- Page navigation doesn’t seem to work when I add offset?
- it’s possible make a WP_Query with math operations?
- show posts with range meta key
- how to write wordpress query for multiple metakeys checking?
- Trying to add a class to post links
- Using a Shortcode to List Posts from Multiple Categories
- How to display a list of posts in same child category as current post
- querying posts with a custom status
- is_404() – where does this get set?
- wp_query on page template not working (Genesis framework)
- Display post meta conditionally based on it’s value
- Max Posts and Memory Limit
- How can i show pagenavi in my author.php?
- Randomly select one of last 3 posts
- Query multiple meta key values for template
- WordPress | WP_Query does not return anything with s=a
- Using WP_Query with multiple loops on one page in search.php
- WP_Query Pagination
- Order by post meta not working with pre_get_posts filter
- WP_Query orderby
- ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)
- Using Ajax and WP_Query to load more posts on category page fails
- is_user_logged_in not working from WP-API (wp-json)
- WordPress private post won’t display to other admins
- Only show tag with the same id as the post
- I have problems with the search query using multiple post types
- ACF: How can I publish values of ACF fields in a loop while using wp_query?
- Sort by price wpdb
- How to check if logged in user have pending custom post?
- WP_Query random ordering not working since 5.4
- Show a message if there are no active posts in category
- How can I re-query post_type and rewrite the url?
- Where my home page and font options has gone?
- How to get the latest post list (of the parent custom custom type)
- Problem with my loops
- Repeat array inside array through while loop
- What’s causing an infinite loop?
- Logging search queries for logged-in users
- pages shortcode filtering by category
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- WP query retrieve the src of attached image
- How to set up pagination for a custom loop on a global template (author.php, tag.php, archive.php?)
- Ignoring ‘a’ when sorting posts
- Featured Image as Background with Offset
- custom WP_Query results in showing same posts in all pagination pages
- counting post from a wp-query using sticky_post
- Duplicate a Query Built with PHP and Mysql but now in WordPress
- How to take parameters from a function and make them editable as attributes in a shortcode
- Show recent posts from excluded category
- What method does this eventually call: do_action_ref_array( ‘parse_query’, array( &$this ) );
- WP_Query secondary query failing
- List posts of terms but exclude one term
- Hiding all posts/products/pages from a site based on a custom taxonomy/domain name
- Custom search (wp query by custom fields)
- pre_get_posts or $where, which one to use?
- Passing query variables to a custom page template
- Query child’s child categories
- $wp_query issue when trying to create a virtual page
- add_query_vars does not work
- Limit the number of posts from a specific category on index.php
- Some images not being returned with wp_get_attachment_image
- Retrieve posts in custom post type and specific taxonomies
- Why is WP_Query’s meta_query not filtering results?
- Get users query makes the site loading time too big?
- Query for page content, and query for posts on the same page?
- How to write short code with if else to get page_id?
- Limit the number of posts via wpquery
- How to retrieve _embed (etc) fields in get_posts custom query?
- WP query with multiple custom meta not respecting orderby
- AJAX search function resets wp_query vars
- I need to get all categories from a WP_Query
- WordPress Ajax search filter on dropdown select
- Unexpected number of loops in while
- Can’t override post type using custom Elementor query
- Passing a variable containing a comma separated list of values in a meta-query
- Adding a language rule and displaying posts with a custom taxonomy term on its archive page
- Use custom url params with value from a custom field to return the post containing the field value
- WP_Query on custom taxonomy -> Location and Activity
- Custom tag template to list posts in ASC order