My .htaccess
files are intercepting WordPress’ .htaccess
file.
Which modules and which settings (specified by .htaccess
) are required for WordPress to work? In other words, where can I find WordPress’ default .htaccess
file?
My .htaccess
files are intercepting WordPress’ .htaccess
file.
Which modules and which settings (specified by .htaccess
) are required for WordPress to work? In other words, where can I find WordPress’ default .htaccess
file?
You must be logged in to post a comment.
Here is the default code for that file.
you can check it here for default htaccess file.
http://codex.wordpress.org/Using_Permalinks.
Thanks. I hope it helps little.
WordPress does not contain
.htaccess
in file form.The rules are written into file by
save_mod_rewrite_rules()
function and are generated by$wp_rewrite->mod_rewrite_rules()
.Note that multisite installation has different (more complex) rules and seems to be handled differently.
Use the latest version of default
.htaccess
https://wordpress.org/support/article/htaccess/.
Use the Freenode’s #wordpress to find the appropriate documentation, usually in the
/topic
. There I found the keyClass WP_Rewrite
here, the official wordpress.org is at the best misleading and marketing. Anyway, do not mix Apache’s rewrite rules with WP’s rewrite rules although the naming of WP is probably from Apache’s equivalent.The WP_Rewrite API states
so you must use the API to do the changes, not fully sure what it means but I think it means you cannot trust in your hard-coded .htaccess -files — things may change even with different WD -versions! So use the API.
The code here has some conditions if the .htaccess -file exists — not 100% of their inferences because not well-documented and cannot understand the naming there but the central message is probably that the safe way to maintain the rewrite rules is to use the WP_Rewrite API, WP may change in the future.
For example, a simple Apache-rewrite
RewriteRule ^hello$ Layouts/hello.html [NC,L]
is apparently something likeadd_rewrite("^hello$", "Layouts/hello.html")
, haven’t tested but tried to follow the API below:Related
http://codex.wordpress.org/Rewrite_API/add_rewrite_rule
http://pmg.co/a-mostly-complete-guide-to-the-wordpress-rewrite-api
Thanks to toscho for assisting here, some small-talk in chat.