WordPress htaccess rules are configurations within the .htaccess file, a powerful tool used by Apache web servers to manage how requests are handled for WordPress sites. These rules enable features such as URL rewriting for clean, SEO-friendly permalinks, which convert dynamic URLs like example.com/?p=123 to user-friendly ones like example.com/post-title. They also support redirects, such as 301 permanent redirects for moved content, enhance site security by blocking malicious access, and optimize performance through caching directives. By default, WordPress generates essential .htaccess rules to ensure proper functionality, but they can be customized for advanced needs like subdirectory installations or custom error pages. Always back up the file before editing to avoid site disruptions.
Table of Contents
- Part 1: OnlineExamMaker – Generate and Share WordPress Htaccess Rules Quiz with AI Automatically
- Part 2: 20 WordPress Htaccess Rules Quiz Questions & Answers
- Part 3: Try OnlineExamMaker AI Question Generator to Create Quiz Questions

Part 1: OnlineExamMaker – Generate and Share WordPress Htaccess Rules Quiz with AI Automatically
OnlineExamMaker is a powerful AI-powered assessment platform to create auto-grading WordPress Htaccess Rules skills assessments. It’s designed for educators, trainers, businesses, and anyone looking to generate engaging quizzes without spending hours crafting questions manually. The AI Question Generator feature allows you to input a topic or specific details, and it generates a variety of question types automatically.
Top features for assessment organizers:
● Prevent cheating by randomizing questions or changing the order of questions, so learners don’t get the same set of questions each time.
● AI Exam Grader for efficiently grading quizzes and assignments, offering inline comments, automatic scoring, and “fudge points” for manual adjustments.
● Embed quizzes on websites, blogs, or share via email, social media (Facebook, Twitter), or direct links.
● Handles large-scale testing (thousands of exams/semester) without internet dependency, backed by cloud infrastructure.
Automatically generate questions using AI
Part 2: 20 WordPress Htaccess Rules Quiz Questions & Answers
or
1. What is the primary purpose of the .htaccess file in a WordPress installation?
A. To manage database connections
B. To handle URL rewriting and server configurations
C. To store theme files
D. To execute PHP scripts directly
Answer: B
Explanation: The .htaccess file is used by Apache servers to configure settings like URL rewriting, which WordPress uses for permalinks, redirects, and security rules.
2. Which directive in .htaccess is commonly used to enforce HTTPS in WordPress?
A. RewriteEngine off
B. Redirect 301 / https://example.com/
C. RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
D. Deny from all
Answer: C
Explanation: The RewriteRule directive redirects all traffic to HTTPS, ensuring secure connections, which is a standard practice for WordPress sites.
3. How can you prevent directory listing in WordPress using .htaccess?
A. Options +Indexes
B. Options -Indexes
C. Index off
D. Listing disable
Answer: B
Explanation: The Options -Indexes directive disables directory listing, enhancing security by preventing visitors from viewing folder contents.
4. What does the following .htaccess rule do: RewriteRule ^old-page$ /new-page [R=301,L]?
A. It creates a temporary redirect
B. It permanently redirects old-page to new-page
C. It blocks access to old-page
D. It caches the page
Answer: B
Explanation: The [R=301,L] flags indicate a permanent (301) redirect and that it’s the last rule to process, commonly used for SEO in WordPress.
5. Which .htaccess rule can protect the wp-config.php file?
A.
B. RewriteRule ^wp-config.php$ – [F]
C. Both A and B
D. Neither A nor B
Answer: C
Explanation: Both methods deny access to wp-config.php; the first uses file-specific directives, and the second uses a rewrite rule to forbid access, bolstering WordPress security.
6. In WordPress, what is the effect of adding RewriteEngine On to .htaccess?
A. It disables URL rewriting
B. It enables the mod_rewrite module for rules
C. It restarts the server
D. It deletes old rules
Answer: B
Explanation: RewriteEngine On activates the Apache mod_rewrite engine, allowing WordPress to process rewrite rules for custom URLs and permalinks.
7. How can you block hotlinking of images in WordPress via .htaccess?
A. RewriteCond %{HTTP_REFERER} !^$ [NC] RewriteRule .*\.(jpg|png)$ – [F]
B. RewriteCond %{HTTP_REFERER} !^https?://(www\.)?example.com [NC] RewriteRule \.(jpg|png)$ – [F,NC]
C. Redirect /images – [F]
D. Deny from all images
Answer: B
Explanation: This rule checks the referrer and blocks access to images if not from the specified domain, preventing bandwidth theft in WordPress.
8. What is the purpose of the [L] flag in a RewriteRule?
A. It logs the rule
B. It makes the rule the last one processed
C. It loops the rule indefinitely
D. It loads a new file
Answer: B
Explanation: The [L] flag stops further processing of rules once the current one is matched, which is essential for efficient WordPress URL handling.
9. Which .htaccess rule can force WWW to non-WWW redirection in WordPress?
A. RewriteCond %{HTTP_HOST} ^www\.example\.com [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
B. Redirect 301 / www.example.com
C. RewriteEngine off
D. Options +FollowSymLinks
Answer: A
Explanation: This rule checks for the WWW subdomain and redirects to the non-WWW version, maintaining consistent URLs for WordPress SEO.
10. How does the following rule affect WordPress:
A. It disables caching
B. It enables browser caching for assets
C. It expires all sessions
D. It activates PHP modules
Answer: B
Explanation: This enables the Expires header, allowing browsers to cache files like images and CSS, which improves WordPress site performance.
11. What does RewriteBase / do in a WordPress .htaccess file?
A. It sets the base URL for all rewrites
B. It rewrites the entire site
C. It bases rules on the root directory
D. Both A and C
Answer: D
Explanation: RewriteBase / specifies the base path for rewrite rules, typically the root, ensuring correct relative URL handling in WordPress.
12. Which directive blocks IP addresses in .htaccess for WordPress security?
A. Allow from 192.168.1.1
B. Deny from 192.168.1.1
C. IP block 192.168.1.1
D. RewriteCond %{REMOTE_ADDR} ^192.168.1.1$ [NC] RewriteRule .* – [F,L]
Answer: D
Explanation: This uses RewriteCond to check the IP and RewriteRule to forbid access, providing a flexible way to block specific IPs in WordPress.
13. In WordPress, what is the role of the # BEGIN WordPress and # END WordPress comments in .htaccess?
A. They mark the section managed by WordPress
B. They comment out rules
C. They begin and end PHP code
D. They are optional and do nothing
Answer: A
Explanation: These comments delineate the area where WordPress automatically updates rewrite rules, preventing manual edits from being overwritten.
14. How can you add a custom 404 error page in WordPress via .htaccess?
A. ErrorDocument 404 /404.html
B. RewriteRule 404 /custom-page
C. Redirect 404 /error-page
D. 404Document /page-not-found
Answer: A
Explanation: The ErrorDocument directive specifies a custom page for 404 errors, improving user experience on WordPress sites.
15. What effect does adding Options +FollowSymLinks have in WordPress .htaccess?
A. It prevents symbolic links
B. It allows the server to follow symbolic links for rewrites
C. It follows external links only
D. It disables links
Answer: B
Explanation: This option enables the server to process symbolic links, which is necessary for some WordPress rewrite rules to function properly.
16. Which .htaccess rule can gzip compress files in WordPress for better performance?
A.
B. Compress all files
C. Gzip on
D. Deflate off
Answer: A
Explanation: This enables mod_deflate to compress specified file types, reducing load times for WordPress assets like HTML, CSS, and JS.
17. How does the rule RewriteCond %{REQUEST_FILENAME} !-f affect WordPress?
A. It checks if the requested file exists
B. It denies access to files
C. It rewrites all files
D. It enables folders only
Answer: A
Explanation: This condition ensures that if the requested file doesn’t exist, the rule proceeds, which is key for WordPress’s permalink system.
18. What is the purpose of using [NC] in a RewriteCond or RewriteRule?
A. It makes the rule case-sensitive
B. It makes the rule case-insensitive
C. It adds a new condition
D. It negates the condition
Answer: B
Explanation: The [NC] flag (No Case) allows the rule to match regardless of letter case, making WordPress rules more flexible and user-friendly.
19. In WordPress, how can you redirect all traffic from HTTP to HTTPS using a simple rule?
A. RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
B. Redirect HTTP to HTTPS
C. HTTPS on
D. RewriteEngine HTTPS
Answer: A
Explanation: This checks if HTTPS is off and redirects to the HTTPS version, ensuring secure traffic for WordPress sites.
20. Which .htaccess addition can help protect against common exploits like directory traversal in WordPress?
A. RewriteCond %{QUERY_STRING} (\.\.|%2e%2e) [NC,OR] RewriteRule .* – [F]
B. Allow traversal
C. Directory protect off
D. RewriteEngine protect
Answer: A
Explanation: This rule blocks requests containing “..” or encoded equivalents, preventing directory traversal attacks on WordPress installations.
or
Part 3: Try OnlineExamMaker AI Question Generator to Create Quiz Questions
Automatically generate questions using AI