Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RewriteRule not working on production server

For my current project I have to Redirect 301 some links but when you enter them with some extra get parameters that parameters need to be suffixed 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 on my production env it does not work, it still redirects to new url but, the get parameters are not appended on the new url.

Edit: It does redirect but it does not append the parameters.

Edit 2: full fill

# 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(s) come before the wordpress part and I have about 30 of them.

Any suggestions?

like image 553
Joren Van Hocht Avatar asked Nov 10 '22 00:11

Joren Van Hocht


1 Answers

Have it 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
like image 172
anubhava Avatar answered Nov 14 '22 23:11

anubhava