Bypass .htaccess when using download_url

You can inject a made-up referer into WordPress’ HTTP request by filtering pre_http_request. All you need is a simple class like this (untested!): class FakeWpReferer { private $referer; private $url; private $is_regex; /** * @param string $referer * @param string $url URL to fake the referer for. * @param bool $is_regex Is $url a regular … Read more

302 redirect instead of 301 after switch to HTTPS

RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.janjippe.nl/$1 [R,L] Your “old” .htaccess file at /public_html/.htaccess would appear to have the suspect 302 redirect. Without an explicit status code, the R flag defaults to a 302. If the entire site has been moved to the /private_html folder as part of the implementation of SSL then it would seem … Read more

Remove year and month in URL using .htaccess

Assuming you have already changed the permalinks structure as @RickHellewell suggests, then you can do something like the following near the top of your .htaccess file (before the existing WP front-controller) to redirect the old URLs (with the stated format) in order to preserve SEO. RewriteRule ^\d{4}/\d\d/([a-z-]+\.html)$ /$1 [R=301,L]

Changing Permalinks to a Custom Permalink causes a 404 Error [no matter what I do]

…remove the <IfModule mod_rewrite.c> wrapper? Or include RewriteEngine On at the top of the .htaccess file, above the <IfModule> wrapper? : @MrWhite Tried it, still get a internal error. That indicates that you don’t have mod_rewrite installed on your server or you are not permitted to use mod_rewrite in .htaccess files (see the AllowOverride directives … Read more

Redirect www to non-www htaccess

This is what you want: RewriteEngine On RewriteCond %{HTTP_HOST} website\.com [NC] RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://website.com/$1 [R,L] @elgoots, the reason yours was close but still had trouble is your HTTP_HOST has the www in it.

Index in root, wordpress in subdirectory

WordPress core in a subdirectory, but accessed via the root folder If you’re trying to move WP to a subdirectory, but access it from the root, use the following approach. Keep your index file in the root, but point it to the proper path: ./SUBDIRECTORY/wp-blog-header.php instead of ./wp-blog-header.php Make sure you change you change the … Read more

Isolating WordPress to a subfolder

If you want your WP site to function completely in subfolder, just set it up there as usual (including .htaccess) and do not add any directives to the root. Setup of .htaccess in root, while WP is in subfolder, is only necessary if you want to have core files (and so admin area) there, but … Read more

Serve apache 404 for missing assets rather then wp 404 template WP_Rewrites

This very helpful page is unfortunately kind of burried on the codex: Basically mod_rewrite_rules hook will do the trick. function faster_htaccess_rules( $rules ){ $faster_rules = <<<EOD \n # BEGIN faster Apache 404 rules RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule \.(jpg|jpeg|png|gif|ico|swf|bmp)$ – [R=404,L] #Use instead for network sites #RewriteRule \.(jpg|jpeg|png|gif|ico|swf|bmp)$ – [nocase,redirect=404,last] # END faster Apache … Read more