Simple .htaccess redirect: how to redirect with options?

My goal is to simply redirect:

/jsn.php?parameters to http://www.site2.com/jsn.php?parameters

I tried using

 Redirect permanent /jsn.php(.)* http://www.site2.com/jsn.php$1 
+4
source share
3 answers

Query string parameters are automatically passed, you just want to do this:

 Redirect permanent /jsn.php http://www.site2.com/jsn.php 

(.)* does not work with the Redirect directive, you are probably thinking about RedirectMatch , but in any case you do not need it. And also (.)* Must be (.*) , Otherwise $ 1 backlink will receive only the first character.

+8
source

You can use explicit URL rewriting in the .htaccess file:

 RewriteRule ^/jsn\.php\?(.*) http://www.site2.com/jsn.php?$1 [R] 

Note: You need to hide. and? because they are also regular expression characters.

If you have a problem using mod_rewrite , post the contents of your file.

0
source

Include mod_rewrite and .htaccess through httpd.conf , and then put this code in .htaccess in the DOCUMENT_ROOT directory:

 Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteRule ^(jsn\.php)$ http://www.site2.com/$1 [L,NC,R=301] 
0
source

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


All Articles