Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2018
    Posts
    65
    Rep Power
    1

    redirect default?page .htaccess


    Hello
    In my migration from blogengine (asp.net) to Wordpress, Search Console signal me error 404 for this:

    Code:
    https://www.mysite.it/default?page=5309
    
    https://www.mysite.it/?name=trap85&page=22671
    page and name can change
    (for example https://www.mysite.it/default?page=1 or https://www.mysite.it/?name=pippo&page=22)

    It's possibile redirect 301 this page to Homepage in htaccess?

    https://www.mysite.it/

    Can you help me?

    THanks

    Fabrizio
  2. #2
  3. Backwards Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,904
    Rep Power
    9646
    For the first one you can use a RewriteRule that looks for /default (you can probably ignore the query string) and redirect to the homepage.

    For the second one, you can use RewriteCond to test the query string for the name= and page= parameters, or maybe just name, and redirect with a RewriteRule.

    Give it a try and if you have problems then post what you wrote.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2018
    Posts
    65
    Rep Power
    1
    Thanks requinix I will try!
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2018
    Posts
    65
    Rep Power
    1
    For first regex I'm making so, but ?page=1 don't go away :-(

    I tried so: RewriteRule ^default/?$ //$1/ [R=301,L]

    result:
    https://www.mysite.it/?page=2

    I don't want ?page=2

    Can you help me?
  8. #5
  9. Backwards Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,904
    Rep Power
    9646
    Ah yes, mod_rewrite has this annoying tendency to append the query string to the new URL if you don't use your own. If you're on Apache 2.4 you can use the Q(uery)S(tring)D(iscard) flag.
    Code:
    RewriteRule ^default/?$ / [R=301,L,QSD]
    Note that $1 is the first capturing group, but you aren't using any so it's meaningless. A mere slash is enough to send the user back to the homepage.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2018
    Posts
    65
    Rep Power
    1
    Thanks I was almost near :-)
    For second I tried so

    RewriteCond %{QUERY_STRING} name=([^&]+) [NC]
    RewriteRule ^/?$ / [L,NC,NE,R=301]


    but i have 500 Internal Server error.... HELPPPP
  12. #7
  13. Backwards Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,904
    Rep Power
    9646
    I don't see anything obviously wrong. What does the error log say is the cause of the 500?
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2018
    Posts
    65
    Rep Power
    1
    error 500 in subdomain (Mysite.it) and "This page does not redirect correctly" in Mysite.it
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2018
    Posts
    65
    Rep Power
    1
    subdomain is test.mysite.it
  18. #10
  19. Backwards Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,904
    Rep Power
    9646
    Okay, but what does the error log say is the cause of the 500?
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2018
    Posts
    65
    Rep Power
    1
    In error log I can not log in is blocked by the host


    In production error is
    This page does not redirect correctly

    Firefox has detected that the server is redirecting the request for this page so that it can never be completed.

    This problem is often caused by blocking or refusing cookies.


    in subdomain

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator at webmaster@test.mysite.it to inform them of the time this error occurred, and the actions you performed just before this error.

    More information about this error may be available in the server error log.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2018
    Posts
    65
    Rep Power
    1
    Perhaps error is order wrong? This is my htaccess... what do you think?

    Code:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    
    RewriteRule ^[0-9]+\..+\.cpaneldcv$ - [L]
    RewriteRule ^\.well-known/acme-challenge/[0-9a-zA-Z_-]+$ - [L]
    RewriteRule ^\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ - [L]
    
    RewriteRule ^default/?$ / [R=301,L,QSD]
    RewriteCond %{QUERY_STRING} name=([^&]+) [NC]
    RewriteRule ^/?$ / [L,NC,NE,R=301]
    
    RewriteCond %{QUERY_STRING} picture=([^&]+) [NC]
    RewriteRule ^image\.axd$ /wp-content/uploads/upload%1? [L,NC,NE,R=301]
    
    RewriteRule ^\d{4}/\d\d/(default) /$1 [R=301,L]
    RewriteRule ^images/(.+?)(?:\.jpgx)?$ /wp-content/uploads/upload/$1 [L,NC,NE,R=301]
    
    # RewriteCond %{QUERY_STRING} .
    # RewriteCond %{QUERY_STRING} !^item= 
    # RewriteCond %{REQUEST_URI} !^/manage
    # RewriteRule .? https://www.mysite.it/%{REQUEST_URI}? [R=301,L] 
    
    RewriteRule ^(.*).aspx$ https://www.mysite.it/$1 [R=301,L]
    RewriteRule ^.*post/\d{4}/\d{2}/\d{2}/(.*) /$1/ [R=301,L]
    RewriteRule ^\d{4}/\d{2}/\d{2}/(.*) /$1/ [R=301,L]
    RewriteRule ^[Bb]log[Ee]ngine/post/(.*) /$1/ [R=301,L]
    RewriteRule ^post/(.*) /$1/ [R=301,L] 
    RewriteRule ^index\.php$ - [L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
  24. #13
  25. Backwards Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,904
    Rep Power
    9646
    Oh, right.

    Remember what I said about query strings being added automatically?
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2018
    Posts
    65
    Rep Power
    1
    sorry what did you say?
  28. #15
  29. Backwards Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,904
    Rep Power
    9646
    Originally Posted by requinix
    Ah yes, mod_rewrite has this annoying tendency to append the query string to the new URL if you don't use your own.
    So, if you take that into account, what will happen when
    Code:
    RewriteCond %{QUERY_STRING} name=([^&]+) [NC]
    RewriteRule ^/?$ / [L,NC,NE,R=301]
    that rule executes?
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo