Googelbot finds my original URI, although I have a working rewrite directivehtaccess SSL redirectHow to...

What options are left, if Britain cannot decide?

Russian cases: A few examples, I'm really confused

Make a transparent 448*448 image

Is Mortgage interest accrued after a December payment tax deductible?

What has been your most complicated TikZ drawing?

Why do Australian milk farmers need to protest supermarkets' milk price?

Making a sword in the stone, in a medieval world without magic

How to answer questions about my characters?

Have researchers managed to "reverse time"? If so, what does that mean for physics?

Professor being mistaken for a grad student

Why using two cd commands in bash script does not execute the second command

Why must traveling waves have the same amplitude to form a standing wave?

How to make healing in an exploration game interesting

Bash: What does "masking return values" mean?

Instead of Universal Basic Income, why not Universal Basic NEEDS?

Where is the 1/8 CR apprentice in Volo's Guide to Monsters?

Fill color and outline color with the same value

Ban on all campaign finance?

Is a lawful good "antagonist" effective?

Informing my boss about remarks from a nasty colleague

Co-worker team leader wants to inject his friend's awful software into our development. What should I say to our common boss?

Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?

The use of "touch" and "touch on" in context

How do I hide Chekhov's Gun?



Googelbot finds my original URI, although I have a working rewrite directive


htaccess SSL redirectHow to redirect a subdomain with subfolders to a domain using the same subfolders and the subdomain itself as parameter?mod_ReWrite to remove part of a URLHow can use mod_rewrite to redirect a multiple specific URLs containing multiple query strings?htaccess mod_rewrite Sub-Directory to Sub-Domainhtaccess redirect with parametersrewrite rule does not rewrite url as expectedHow To Force Rewrite and Redirect UrlHow to Permanently redirect URLs based on conditions.htaccess rewriterule if/else













-1















I have :



RewriteRule ^Article/([^/]*)$ /article.php?newsid=$1 [L]


Which means that the URL must be //example.com/Article/855563
but Google crawls //example.com/article.php?newsid=855563.
Is there anything I can do to prevent this? Or to redirect 301 to example.com/Article/855563?










share|improve this question









New contributor




Nimer Sulieman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2





    you might want to format your question properly, additionally i doubt you are the owner of domain.com, please use the properly designed domain for that (hint f.e example.com) for example look here iana.org/domains/reserved as for your question, it is lacking a lot of information about your system. read serverfault.com/help for details. as for your question itself: test it yourself, curl/wget or similiar tools which are able to access your website are available and can be used to check if a rewrite rule is working properly.

    – Dennis Nolte
    9 hours ago











  • From your question I understand that the google bot is Crawling //domain.com/article.php?newsid=855563 instead of //domain.com/Article/855563. Try - RewriteRule ^Article/([^/]*)$ /Article/$1 [NC,L]

    – mightyteja
    5 hours ago


















-1















I have :



RewriteRule ^Article/([^/]*)$ /article.php?newsid=$1 [L]


Which means that the URL must be //example.com/Article/855563
but Google crawls //example.com/article.php?newsid=855563.
Is there anything I can do to prevent this? Or to redirect 301 to example.com/Article/855563?










share|improve this question









New contributor




Nimer Sulieman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2





    you might want to format your question properly, additionally i doubt you are the owner of domain.com, please use the properly designed domain for that (hint f.e example.com) for example look here iana.org/domains/reserved as for your question, it is lacking a lot of information about your system. read serverfault.com/help for details. as for your question itself: test it yourself, curl/wget or similiar tools which are able to access your website are available and can be used to check if a rewrite rule is working properly.

    – Dennis Nolte
    9 hours ago











  • From your question I understand that the google bot is Crawling //domain.com/article.php?newsid=855563 instead of //domain.com/Article/855563. Try - RewriteRule ^Article/([^/]*)$ /Article/$1 [NC,L]

    – mightyteja
    5 hours ago
















-1












-1








-1








I have :



RewriteRule ^Article/([^/]*)$ /article.php?newsid=$1 [L]


Which means that the URL must be //example.com/Article/855563
but Google crawls //example.com/article.php?newsid=855563.
Is there anything I can do to prevent this? Or to redirect 301 to example.com/Article/855563?










share|improve this question









New contributor




Nimer Sulieman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have :



RewriteRule ^Article/([^/]*)$ /article.php?newsid=$1 [L]


Which means that the URL must be //example.com/Article/855563
but Google crawls //example.com/article.php?newsid=855563.
Is there anything I can do to prevent this? Or to redirect 301 to example.com/Article/855563?







.htaccess mod-rewrite googlebot






share|improve this question









New contributor




Nimer Sulieman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Nimer Sulieman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 1 min ago









MrWhite

6,08521425




6,08521425






New contributor




Nimer Sulieman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 10 hours ago









Nimer SuliemanNimer Sulieman

6




6




New contributor




Nimer Sulieman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Nimer Sulieman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Nimer Sulieman is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 2





    you might want to format your question properly, additionally i doubt you are the owner of domain.com, please use the properly designed domain for that (hint f.e example.com) for example look here iana.org/domains/reserved as for your question, it is lacking a lot of information about your system. read serverfault.com/help for details. as for your question itself: test it yourself, curl/wget or similiar tools which are able to access your website are available and can be used to check if a rewrite rule is working properly.

    – Dennis Nolte
    9 hours ago











  • From your question I understand that the google bot is Crawling //domain.com/article.php?newsid=855563 instead of //domain.com/Article/855563. Try - RewriteRule ^Article/([^/]*)$ /Article/$1 [NC,L]

    – mightyteja
    5 hours ago
















  • 2





    you might want to format your question properly, additionally i doubt you are the owner of domain.com, please use the properly designed domain for that (hint f.e example.com) for example look here iana.org/domains/reserved as for your question, it is lacking a lot of information about your system. read serverfault.com/help for details. as for your question itself: test it yourself, curl/wget or similiar tools which are able to access your website are available and can be used to check if a rewrite rule is working properly.

    – Dennis Nolte
    9 hours ago











  • From your question I understand that the google bot is Crawling //domain.com/article.php?newsid=855563 instead of //domain.com/Article/855563. Try - RewriteRule ^Article/([^/]*)$ /Article/$1 [NC,L]

    – mightyteja
    5 hours ago










2




2





you might want to format your question properly, additionally i doubt you are the owner of domain.com, please use the properly designed domain for that (hint f.e example.com) for example look here iana.org/domains/reserved as for your question, it is lacking a lot of information about your system. read serverfault.com/help for details. as for your question itself: test it yourself, curl/wget or similiar tools which are able to access your website are available and can be used to check if a rewrite rule is working properly.

– Dennis Nolte
9 hours ago





you might want to format your question properly, additionally i doubt you are the owner of domain.com, please use the properly designed domain for that (hint f.e example.com) for example look here iana.org/domains/reserved as for your question, it is lacking a lot of information about your system. read serverfault.com/help for details. as for your question itself: test it yourself, curl/wget or similiar tools which are able to access your website are available and can be used to check if a rewrite rule is working properly.

– Dennis Nolte
9 hours ago













From your question I understand that the google bot is Crawling //domain.com/article.php?newsid=855563 instead of //domain.com/Article/855563. Try - RewriteRule ^Article/([^/]*)$ /Article/$1 [NC,L]

– mightyteja
5 hours ago







From your question I understand that the google bot is Crawling //domain.com/article.php?newsid=855563 instead of //domain.com/Article/855563. Try - RewriteRule ^Article/([^/]*)$ /Article/$1 [NC,L]

– mightyteja
5 hours ago












1 Answer
1






active

oldest

votes


















0














You first need to identify why Google is crawling the wrong URLs.




  • Did you change an existing URL structure (that had been indexed by search engines and linked to externally)? In which case you would have needed to have implemented a redirect from the old URL to the new in order to preserve SEO and get search engines to replace the old URLs in the SERPs.


  • Are you inadvertently linking to the wrong URL(s) internally and exposing the "wrong" URLs to search engines? If so, these must be fixed before implementing the redirect.



Otherwise, Google should not have been able to discover the "wrong" URLs.



You should also be implementing a rel="canonical" tag in the head of your pages to indicate the correct canonical URL to search engines.



In order to externally redirect a URL of the form /article.php?newsid=<newsid> to /Article/<newsid> (the canonical URL) - the reverse of the existing internal rewrite - then you can do something like the following near the top of your .htaccess file (before the existing rewrite):



RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^newsid=([^&]*)
RewriteRule ^article.php$ /Article/%1 [R=302,L]


The first condition that checks against the REDIRECT_STATUS environment variable is necessary in order to prevent a redirect loop - it ensures that the rule is only processed on direct requests from the client and not rewritten requests (your existing directive).



The second condition captures the value of the newsid URL parameter (that occurs at the start of the URL path). This is saved in the %1 backreference (used later in the RewriteRule substitution). Note that this captures anything (as in your rewrite), however, if the newsid value is always numeric then this should really be made more restrictive. eg. ^newsid=(d+) (1 or more digits only).



Note that this is currently a 302 (temporary) redirect. Only change it to a 301 (permanent) redirect once you have confirmed that it works OK - in order to avoid any caching issues.





share























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "2"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Nimer Sulieman is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f958256%2fgoogelbot-finds-my-original-uri-although-i-have-a-working-rewrite-directive%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You first need to identify why Google is crawling the wrong URLs.




    • Did you change an existing URL structure (that had been indexed by search engines and linked to externally)? In which case you would have needed to have implemented a redirect from the old URL to the new in order to preserve SEO and get search engines to replace the old URLs in the SERPs.


    • Are you inadvertently linking to the wrong URL(s) internally and exposing the "wrong" URLs to search engines? If so, these must be fixed before implementing the redirect.



    Otherwise, Google should not have been able to discover the "wrong" URLs.



    You should also be implementing a rel="canonical" tag in the head of your pages to indicate the correct canonical URL to search engines.



    In order to externally redirect a URL of the form /article.php?newsid=<newsid> to /Article/<newsid> (the canonical URL) - the reverse of the existing internal rewrite - then you can do something like the following near the top of your .htaccess file (before the existing rewrite):



    RewriteEngine On

    RewriteCond %{ENV:REDIRECT_STATUS} ^$
    RewriteCond %{QUERY_STRING} ^newsid=([^&]*)
    RewriteRule ^article.php$ /Article/%1 [R=302,L]


    The first condition that checks against the REDIRECT_STATUS environment variable is necessary in order to prevent a redirect loop - it ensures that the rule is only processed on direct requests from the client and not rewritten requests (your existing directive).



    The second condition captures the value of the newsid URL parameter (that occurs at the start of the URL path). This is saved in the %1 backreference (used later in the RewriteRule substitution). Note that this captures anything (as in your rewrite), however, if the newsid value is always numeric then this should really be made more restrictive. eg. ^newsid=(d+) (1 or more digits only).



    Note that this is currently a 302 (temporary) redirect. Only change it to a 301 (permanent) redirect once you have confirmed that it works OK - in order to avoid any caching issues.





    share




























      0














      You first need to identify why Google is crawling the wrong URLs.




      • Did you change an existing URL structure (that had been indexed by search engines and linked to externally)? In which case you would have needed to have implemented a redirect from the old URL to the new in order to preserve SEO and get search engines to replace the old URLs in the SERPs.


      • Are you inadvertently linking to the wrong URL(s) internally and exposing the "wrong" URLs to search engines? If so, these must be fixed before implementing the redirect.



      Otherwise, Google should not have been able to discover the "wrong" URLs.



      You should also be implementing a rel="canonical" tag in the head of your pages to indicate the correct canonical URL to search engines.



      In order to externally redirect a URL of the form /article.php?newsid=<newsid> to /Article/<newsid> (the canonical URL) - the reverse of the existing internal rewrite - then you can do something like the following near the top of your .htaccess file (before the existing rewrite):



      RewriteEngine On

      RewriteCond %{ENV:REDIRECT_STATUS} ^$
      RewriteCond %{QUERY_STRING} ^newsid=([^&]*)
      RewriteRule ^article.php$ /Article/%1 [R=302,L]


      The first condition that checks against the REDIRECT_STATUS environment variable is necessary in order to prevent a redirect loop - it ensures that the rule is only processed on direct requests from the client and not rewritten requests (your existing directive).



      The second condition captures the value of the newsid URL parameter (that occurs at the start of the URL path). This is saved in the %1 backreference (used later in the RewriteRule substitution). Note that this captures anything (as in your rewrite), however, if the newsid value is always numeric then this should really be made more restrictive. eg. ^newsid=(d+) (1 or more digits only).



      Note that this is currently a 302 (temporary) redirect. Only change it to a 301 (permanent) redirect once you have confirmed that it works OK - in order to avoid any caching issues.





      share


























        0












        0








        0







        You first need to identify why Google is crawling the wrong URLs.




        • Did you change an existing URL structure (that had been indexed by search engines and linked to externally)? In which case you would have needed to have implemented a redirect from the old URL to the new in order to preserve SEO and get search engines to replace the old URLs in the SERPs.


        • Are you inadvertently linking to the wrong URL(s) internally and exposing the "wrong" URLs to search engines? If so, these must be fixed before implementing the redirect.



        Otherwise, Google should not have been able to discover the "wrong" URLs.



        You should also be implementing a rel="canonical" tag in the head of your pages to indicate the correct canonical URL to search engines.



        In order to externally redirect a URL of the form /article.php?newsid=<newsid> to /Article/<newsid> (the canonical URL) - the reverse of the existing internal rewrite - then you can do something like the following near the top of your .htaccess file (before the existing rewrite):



        RewriteEngine On

        RewriteCond %{ENV:REDIRECT_STATUS} ^$
        RewriteCond %{QUERY_STRING} ^newsid=([^&]*)
        RewriteRule ^article.php$ /Article/%1 [R=302,L]


        The first condition that checks against the REDIRECT_STATUS environment variable is necessary in order to prevent a redirect loop - it ensures that the rule is only processed on direct requests from the client and not rewritten requests (your existing directive).



        The second condition captures the value of the newsid URL parameter (that occurs at the start of the URL path). This is saved in the %1 backreference (used later in the RewriteRule substitution). Note that this captures anything (as in your rewrite), however, if the newsid value is always numeric then this should really be made more restrictive. eg. ^newsid=(d+) (1 or more digits only).



        Note that this is currently a 302 (temporary) redirect. Only change it to a 301 (permanent) redirect once you have confirmed that it works OK - in order to avoid any caching issues.





        share













        You first need to identify why Google is crawling the wrong URLs.




        • Did you change an existing URL structure (that had been indexed by search engines and linked to externally)? In which case you would have needed to have implemented a redirect from the old URL to the new in order to preserve SEO and get search engines to replace the old URLs in the SERPs.


        • Are you inadvertently linking to the wrong URL(s) internally and exposing the "wrong" URLs to search engines? If so, these must be fixed before implementing the redirect.



        Otherwise, Google should not have been able to discover the "wrong" URLs.



        You should also be implementing a rel="canonical" tag in the head of your pages to indicate the correct canonical URL to search engines.



        In order to externally redirect a URL of the form /article.php?newsid=<newsid> to /Article/<newsid> (the canonical URL) - the reverse of the existing internal rewrite - then you can do something like the following near the top of your .htaccess file (before the existing rewrite):



        RewriteEngine On

        RewriteCond %{ENV:REDIRECT_STATUS} ^$
        RewriteCond %{QUERY_STRING} ^newsid=([^&]*)
        RewriteRule ^article.php$ /Article/%1 [R=302,L]


        The first condition that checks against the REDIRECT_STATUS environment variable is necessary in order to prevent a redirect loop - it ensures that the rule is only processed on direct requests from the client and not rewritten requests (your existing directive).



        The second condition captures the value of the newsid URL parameter (that occurs at the start of the URL path). This is saved in the %1 backreference (used later in the RewriteRule substitution). Note that this captures anything (as in your rewrite), however, if the newsid value is always numeric then this should really be made more restrictive. eg. ^newsid=(d+) (1 or more digits only).



        Note that this is currently a 302 (temporary) redirect. Only change it to a 301 (permanent) redirect once you have confirmed that it works OK - in order to avoid any caching issues.






        share











        share


        share










        answered 3 mins ago









        MrWhiteMrWhite

        6,08521425




        6,08521425






















            Nimer Sulieman is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Nimer Sulieman is a new contributor. Be nice, and check out our Code of Conduct.













            Nimer Sulieman is a new contributor. Be nice, and check out our Code of Conduct.












            Nimer Sulieman is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Server Fault!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f958256%2fgoogelbot-finds-my-original-uri-although-i-have-a-working-rewrite-directive%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            117736 Шеррод Примітки | Див. також | Посилання | Навігаційне...

            As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

            Маріан Котлеба Зміст Життєпис | Політичні погляди |...