Setup Permanent 301 Redirects after moving to Https [closed]

RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR] RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC] RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC] This will result in a redirect loop as it will repeatedly redirect https://www.xxxz.com.qa/<url> to https://www.xxxz.com.qa/<url> again and again… If you want to redirect from HTTP then you need to check that the request was for HTTP before redirecting to HTTPS. For example: RewriteCond … Read more

Error “Call to a member function switch_to_locale() on null” during insert_with_markers

From your comment: Those htaccess changes don’t happen as a result of an add_action. Perhaps they should? Yes, they should. And here’s why insert_with_markers() calls switch_to_locale() which uses $GLOBALS[‘wp_locale_switcher’] (or $wp_locale_switcher) which is initialized in wp-settings.php, but only after WordPress runs the setup_theme hook. And looking at the error in question and line #1582 in … Read more

Remove special characters in a URL

http://www.example.com/ar/shop-listing/health-beauty~@/#$&&&%%$%3Cscript%3E/ In this particular URL, everything after the # (hash) is the fragment identifier and is not sent to the server by the browser, so cannot be blocked server-side in .htaccess. The server only sees: /ar/shop-listing/health-beauty~@/ If the # was to be removed from this URL then this would be a wholly invalid URL (because … Read more

Redirect main domain to subdirectory

From the two .htaccess files you posted I can’t see how your site is working at all?! If you request example.com/ (the document root) then the second rule in the root .htaccess file rewrites the request directly to /subdirectory/index.html (not index.php). If /subdirectory/index.html exists then the (non-WordPress) file is served, otherwise see #2 If you … Read more

Redirect “any page/page/number/” to “any page”

I’d like to redirect in ht.access To clarify, it’s .htaccess, not ht.access. You can do something like the following at the top of the .htaccess file, before the existing WordPress directvies: RewriteRule (.*/)page/\d+/?$ /$1 [R=302,L] The above issues a 302 (temporary) redirect for any URL of the form /<something>/page/<number>/ (trailing slash optional) to /<something>/. The … Read more