Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hello,

I have set some 301 redirects in the Htaccess file of my site, to redirect some old URLs to the new ones.

Here's an example of how it's written in the file :

Code: Select all
Redirect 301 /john-doe https://example.com/class/page-name.html


But if I visit that "john-doe" URL :
Code: Select all
https://example.domain.com/john-doe

(which doesn't exist anymore)

It sends me to the right page set in the 301 rule, but it adds :
Code: Select all
/?fname=john-doe

to the URL.
So the URL I'm being redirected to becomes :
Code: Select all
https://example.com/class/page-name.html/?fname=john-doe


Which gives me a 404 Not found error. But if I delete that "/?fname=john-doe" part, the url loads just fine.

Any ideas why this is happening?
I haven't edited anything in the htaccess file except adding few 301 redirects lines, formatted exactly how I have typed it earlier in the post.
I have added those lines after this block :

Code: Select all
#If your site begins with 'www', uncomment the following two lines
#RewriteCond %{HTTP_HOST} !^www\.
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]


Before this line :
Code: Select all
#DO NOT EDIT BELOW THIS


Any help will be gladly appreciated.
Thank you
Please try placing the rule just below the following block in your .htaccess -
Code: Select all
#DO NOT EDIT BELOW THIS
..
..
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [L]

You may try using the following rule which has worked for me in the past -
Code: Select all
RewriteRule ^/john-doe https://example.com/class/page-name.html [R=301,L,QSA]

So the code will now become as follows -
Code: Select all
#DO NOT EDIT BELOW THIS
..
..
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule . - [L]

RewriteRule ^/john-doe https://example.com/class/page-name.html [R=301,L,QSA]

Hope it helps.
Hi KK,

Thanks.
But it didn't worked.

What worked though is this snippet that I used in the past on another site on our server :

Code: Select all
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^old-page https://example.domain.com/new-page.html [QSD,L,R=301]


Which is pretty much what you said, but for some reasons this snippet worked (maybe related to the HTTPS certificate?)

Thanks a lot for your time!
larin555 wrote: Which is pretty much what you said, but for some reasons this snippet worked


Seems like because of QSD.
4 posts Page 1 of 1