I have a "little problem" with .htaccess and WordPress and hope someone can give ma a hint to solve it.
I need a rewrite rule that catches the domain without "www." or "https/www." to be more specific it should route from example.com/code ( without http://www. ) to rewrite rule https://www.example.com/?productcode=*code*. I tried to put the rewrite rule bevor the WordPress .htaccess part and after but it all ended up with an error - I'm stuck
the standard .htaccess in WordPress:
My Wordpress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
The Productcode is 1 to 7 digits long and contains only Characters 0-9 A-Z and a-z. I used the [L] when i put the rewrite rule at the beginning of the rules.
The rewrite rule was inserted manually in WordPress for testing - which is not a good idea since it will be overwritten by WordPress, it will be later ( when I know the it works added via functions.php)
My rewrite rule:
RewriteRule ^example\.com/[a-zA-Z0-9]{1,7}$ https://www.example.com/productcode=$1 [L]
I understood that "^" is the beginning of the rule and excludes "www." or "https://www", then follows the domain and the code, which can be 1-7 digits long, which is then redirected to https://www.example.com/productcode=$1 and all of the other sites are not infected by by rule, or am I wrong?