Cleanup URL for a custom page in wordpress

You can do this with the internal rewrite system, which is parsed in php, not htaccess. First, add the rule. This assumes you have created a root page under Pages with the slug dictionary. function wpd_dictionary_rewrite(){ add_rewrite_tag( ‘%dictionary_word%’, ‘([^/]+)’ ); add_rewrite_rule( ‘^dictionary/([^/]+)/?$’, ‘index.php?pagename=dictionary&dictionary_word=$matches[1]’, ‘top’ ); } add_action( ‘init’, ‘wpd_dictionary_rewrite’ ); This code would go in … Read more

Rewrite rule to load images from production does nothing

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] # If images not found on development site, load from production RewriteCond %{REQUEST_URI} ^/wp-content/uploads/[^\/]*/.*$ RewriteRule ^(.*)$ https://www.example.com/$1 [QSA,L] The problem here is that “If images not found on development site” then the request has already been rewritten to index.php by the preceding RewriteRule (WordPress front-controller), … Read more

Deny access to a path (give 403 or 404 response)

# this give internal server error throughout site: <Files ~ “/users/”> Header set X-Robots-Tag “noindex, nofollow” </FilesMatch> This would give an “internal server error” (500 response) because you’ve used </FilesMatch> to close the <Files> section. It should be </Files>. But as you suggested, this won’t work anyway, as the <Files> directive matches real files only, … Read more

Site searches by Python for non-existent assets

What are the python searches? Are they like bad bots? Most probably just “bad bots” searching for potential vulnerabilities. How do I block or prevent them? Well, you are already serving a 404 by the sounds of it, so it’s really a non-issue. However, you can prevent the request from going through WordPress by blocking … Read more

Remove / from www.example.com/ [closed]

This isn’t a WordPress thing, this is a browser/HTTP thing. Firefox may be showing the / as part of a setting, but example.com and example.com/ are the same URL. This Q on webmasters goes into more detail as to why this is the case: https://webmasters.stackexchange.com/questions/35643/is-trailing-slash-automagically-added-on-click-of-home-page-url-in-browser

How can I serve a text file at a custom URL

You can utilize add_rewrite_rule to create a new endpoint like http://example.com/api/files/xyz which processes the request and renders the contents from your server. This allows you to mask the origin of the file but still access it’s content. add_rewrite_rule requires you flush_rewrite_rules but you only need to do that once every time you make a change … Read more

How to redirect from various ?page_id= to home page?

You can’t match the query string using a mod_alias RedirectMatch directive. This directive matches against the URL-path only. You need to use mod_rewrite instead, with a condition that checks the QUERY_STRING server variable. For example, at the top of your .htaccess file, try the following: RewriteCond %{QUERY_STRING} ^page_id=\d+$ RewriteRule ^$ / [QSD,R=302,L] The QSD flag … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)