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

WordPress redirect all 404 pages to the Homepage

Note: I have read somewhere that redirecting all 404 to Homepage is not a good approach for SEO purposes Simplest way to redirect all 404 to homepage in wordpress. if( !function_exists(‘redirect_404_to_homepage’) ){ add_action( ‘template_redirect’, ‘redirect_404_to_homepage’ ); function redirect_404_to_homepage(){ if(is_404()): wp_safe_redirect( home_url(“https://wordpress.stackexchange.com/”) ); exit; endif; } }

https redirect (with .htaccess) redirect loop

I’d steer clear on editing the .htaccess if you’re just updating your website from HTTP to HTTPS. Try an alternative route: First, revert your .htaccess back to the default settings: # 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> # … Read more

Question with loading 403/ 404 error pages and htaccess

it create a never-ending loop as WordPress tries to find the 403.php page Not WordPress, but Apache. WordPress never even sees the request. You need to make an exception for your custom 403 error document, otherwise, the directives you have posted would issue another 403 for the error document itself… an endless loop. If your … Read more