Redirect subdomain in Multisite installation?

RewriteRule ^(.*)$ https://example.com/summer/$1 [R=301] You need to include the L flag on the RewriteRule directive, ie. [R=301,L] and ensure this rule is near the top of the .htaccess file, before the existing WordPress directives. Without the L flag, processing continues and the request is further rewritten (by the WordPress front-controller) before the eventual (incorrect) redirect.

Changed permalink structure. Need help with redirecting old posts

…it redirected the old URLs to the new URLs without the end trailing slash and then redirected again with the trailing slash. So, it generated 2 redirects instead of one. RedirectMatch 301 ^/([^/]+)/([0-9]{4})/([0-9]{2})/([^/]+)/$ https://www.example.com/$4 In that case you should simply be able to append a trailing slash to the target URL in the above directive … Read more

htaccess – RewriteRule without redirect not working

You can add a rewrite rule to map to one of those pages with something like this: add_action( ‘init’, function() { add_rewrite_rule( ‘myparamname/([a-z0-9-]+)[/]?$’, ‘index.php?myparamname=$matches[1]’, ‘top’ ); } ); The first parameter of add_rewrite_rule is a regular expression to match a URL. The second parameter is an index.php non-pretty permalink URL, the URL parameters map directly … Read more

How To Allow Only Specific User Agent To Access a URL?

There are at aleast two ways you can block other user agents and allow only a few. This can be done by editing the .htaccess file in the root directory of your WordPress website. Option 1 Using mod_rewrite, add the code below at the top of your .htaccess file. <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_USER_AGENT} … Read more

Redirect parent taxonomy to it’s child

Assuming state and city are variable path segments, so you are essentially redirecting /investments/<one>/<two>/ to /investments/<two>/ then try the following at the top of your .htaccess file: # Redirect “/investments/<one>/<two>/” to “/investments/<two>/” RewriteRule ^(investments)/[^/]+/([^/]+)/$ /$1/$2/ [R=302,L] If you need any further explanation then just ask in comments. UPDATE: I’ve added an end-of-string anchor ($) to … Read more

set up 301 redirect within wp-content/uploads/ directory of a WP site to a new image URL

If this image does not exist then the request will be rewritten to the WordPress front-controller before your redirect occurs. Try the following instead using mod_rewrite at the top of the .htaccess file, before the # BEGIN WordPress code block: RewriteRule ^(wp-content/uploads/2021/09)/image-1\.png$ https://%{HTTP_HOST}/$1/image-2.png [R=302,L] The $1 backreference in the substitution string simply avoids having to … Read more

Use virtual pages point to one specific page

I actually found a rather easy way to achieve this: add_rewrite_rule( ‘city/([a-zA-Z]+)/?$’, ‘wp-content/plugins/csv-to-html/templates/csvtohtmlpage_core.php?city=$1’ ); Yes, I know I did not mention city/ in the beginning but I just wanted wanted to know how should I achieve this. If someone has better ideas. Please tell me! 🙂

htaccess rules not applied?

Your rules are in the wrong order. Your “Custom Redirect” needs to be at the top of the .htaccess file before the WordPress front-controller, ie. before the # BEGIN WordPress comment marker. By placing it after the WordPress code block it will only get processed for requests that map directly to files and directories (including … Read more

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