Internal rewrite redirection appears in redirection

I use the following htaccess

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301]
    RewriteRule ^user/([^/]*)/$ /user/index.php?usr=$1

The first three lines redirect the non-www URL to the site for my website ..

Another line redirects for canonical assignment, for example. www.mysite.com/user/index.php?usr=JAHAJEEwill become www.mysite.com/user/JAHAJEE/.

My problem is that after adding the above redirects for non www to www, canonical redirected pages show the url parameter (e.g. www.www.mysite.com/user/JAHAJEE/?usr=JAHAJEE). Please check http://www.jahajee.com/user/JAHAJEE/ and http://jahajee.com/user/JAHAJEE/

How to prevent URL parameters from displaying in the redirected URL. Thank you in advance.

+4
source share
2 answers

[R=301]tells mod_rewrite that the request should be redirected, but the request will not be redirected instantly. It will evaluate the rules until it finds a flag [L]or [END](or gets to the end of the file). Now it matches the first rule and says that when mod_rewrite feels ready, it should redirect. mod_rewrite has not yet found a flag Lor ENDand still has rules to match. Then it will comply with the second rule and will include a redirect.

[R=301,L], . .htaccess, . .

+7

, 301 303
301 303

0

All Articles