Trying to mask url using htaccess












0















I am trying to understand htaccess to use it in my project, but for the past 3 hours I have hit a wall.



I took off the file extension and put a trailing / behind my url, but now im trying to hide a specific folder in the url and mascarade another one.



http://localhost/WWI/partials/producten/producten_product/ is my current url and I am trying to change this to :



http://localhost/WWI/producten/product/



This is my current htacces code I use for the trailing / and the file extension:



<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /WWI/

#Hides .php extension snippet
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).php [NC]
RewriteRule ^ %1/ [R,L]

#Adds a trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !/$
RewriteRule . %{REQUEST_URI}/ [L,R=301]

#Internally forwards /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]


#THIS IS THE PART IM TRYING TO FIX RIGHT NOW
RewriteRule ^/?$ /partials/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /partials/$1 [L]

</IfModule>


Ive tried a lot of things people asked here already, if needed I can add these tries to this post.



But can anyone give me a push in the right direction, so that I can get this result:



http://localhost/WWI/producten/product/



Thank you in advance.



OK, Ive added:



RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^product_individueel/(.*)$ product_individueel.php?q=$1


Wich does actually mask the url, but then it gives an error saying: 'Error, to many redirects'










share|improve this question





























    0















    I am trying to understand htaccess to use it in my project, but for the past 3 hours I have hit a wall.



    I took off the file extension and put a trailing / behind my url, but now im trying to hide a specific folder in the url and mascarade another one.



    http://localhost/WWI/partials/producten/producten_product/ is my current url and I am trying to change this to :



    http://localhost/WWI/producten/product/



    This is my current htacces code I use for the trailing / and the file extension:



    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /WWI/

    #Hides .php extension snippet
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).php [NC]
    RewriteRule ^ %1/ [R,L]

    #Adds a trailing slash
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !/$
    RewriteRule . %{REQUEST_URI}/ [L,R=301]

    #Internally forwards /dir/foo to /dir/foo.php
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*?)/?$ $1.php [L]


    #THIS IS THE PART IM TRYING TO FIX RIGHT NOW
    RewriteRule ^/?$ /partials/ [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /partials/$1 [L]

    </IfModule>


    Ive tried a lot of things people asked here already, if needed I can add these tries to this post.



    But can anyone give me a push in the right direction, so that I can get this result:



    http://localhost/WWI/producten/product/



    Thank you in advance.



    OK, Ive added:



    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteRule ^product_individueel/(.*)$ product_individueel.php?q=$1


    Wich does actually mask the url, but then it gives an error saying: 'Error, to many redirects'










    share|improve this question



























      0












      0








      0


      1






      I am trying to understand htaccess to use it in my project, but for the past 3 hours I have hit a wall.



      I took off the file extension and put a trailing / behind my url, but now im trying to hide a specific folder in the url and mascarade another one.



      http://localhost/WWI/partials/producten/producten_product/ is my current url and I am trying to change this to :



      http://localhost/WWI/producten/product/



      This is my current htacces code I use for the trailing / and the file extension:



      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /WWI/

      #Hides .php extension snippet
      RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).php [NC]
      RewriteRule ^ %1/ [R,L]

      #Adds a trailing slash
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_URI} !/$
      RewriteRule . %{REQUEST_URI}/ [L,R=301]

      #Internally forwards /dir/foo to /dir/foo.php
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME}.php -f
      RewriteRule ^(.*?)/?$ $1.php [L]


      #THIS IS THE PART IM TRYING TO FIX RIGHT NOW
      RewriteRule ^/?$ /partials/ [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ /partials/$1 [L]

      </IfModule>


      Ive tried a lot of things people asked here already, if needed I can add these tries to this post.



      But can anyone give me a push in the right direction, so that I can get this result:



      http://localhost/WWI/producten/product/



      Thank you in advance.



      OK, Ive added:



      RewriteCond %{SCRIPT_FILENAME} !-d
      RewriteCond %{SCRIPT_FILENAME} !-f
      RewriteRule ^product_individueel/(.*)$ product_individueel.php?q=$1


      Wich does actually mask the url, but then it gives an error saying: 'Error, to many redirects'










      share|improve this question
















      I am trying to understand htaccess to use it in my project, but for the past 3 hours I have hit a wall.



      I took off the file extension and put a trailing / behind my url, but now im trying to hide a specific folder in the url and mascarade another one.



      http://localhost/WWI/partials/producten/producten_product/ is my current url and I am trying to change this to :



      http://localhost/WWI/producten/product/



      This is my current htacces code I use for the trailing / and the file extension:



      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /WWI/

      #Hides .php extension snippet
      RewriteCond %{THE_REQUEST} ^[A-Z]{3,}s([^.]+).php [NC]
      RewriteRule ^ %1/ [R,L]

      #Adds a trailing slash
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_URI} !/$
      RewriteRule . %{REQUEST_URI}/ [L,R=301]

      #Internally forwards /dir/foo to /dir/foo.php
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME}.php -f
      RewriteRule ^(.*?)/?$ $1.php [L]


      #THIS IS THE PART IM TRYING TO FIX RIGHT NOW
      RewriteRule ^/?$ /partials/ [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ /partials/$1 [L]

      </IfModule>


      Ive tried a lot of things people asked here already, if needed I can add these tries to this post.



      But can anyone give me a push in the right direction, so that I can get this result:



      http://localhost/WWI/producten/product/



      Thank you in advance.



      OK, Ive added:



      RewriteCond %{SCRIPT_FILENAME} !-d
      RewriteCond %{SCRIPT_FILENAME} !-f
      RewriteRule ^product_individueel/(.*)$ product_individueel.php?q=$1


      Wich does actually mask the url, but then it gives an error saying: 'Error, to many redirects'







      .htaccess url-rewriting url-routing






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 '18 at 13:17







      H. Brendan

















      asked Nov 15 '18 at 11:39









      H. BrendanH. Brendan

      654227




      654227
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53318680%2ftrying-to-mask-url-using-htaccess%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f53318680%2ftrying-to-mask-url-using-htaccess%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







          這個網誌中的熱門文章

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud

          Zucchini