RewriteRule does not work on production server

For my current project, I have to redirect some 301 links, but when you enter them with some additional receive parameters, the parameters should be suffix on the new URL.

Example:

Old: / language / nl / article -1 /? test = 123

new: / Language / nl / fa1-artcile-1 /? Test = 123

So I use the following code: (which works fine on my dev env)

RewriteEngine On Options +FollowSymLinks RewriteBase /language/nl RewriteRule /artcile-1/* /language/nl/fa1-artcile-1/$1 [R=301,L] 

But once at my work env it does not work, it is still redirected to the new url, but get parameters are not added to the new url.

Edit: it redirects but does not add parameters.

Edit 2: full occupancy

 # 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> # END WordPress 

The rewrite rule occurs before the wordpress part, and I have about 30 of them.

Any suggestions?

+5
source share
3 answers

Like this:

 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteRule ^language/nl/article-1/?$ /language/nl/fa1-artcile-1/ [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress 
+1
source

You need to add a query string:

 # 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,QSA] </IfModule> # END WordPress 
0
source

Probably the other answers here are correct. But for my case, they will not work.

In env, it works like MS Azure env, so I need to have a web.config file instead of a .htaccess file (however, it works for some part).

Thanks for all the quick help and thinking!

0
source

Source: https://habr.com/ru/post/1237382/


All Articles