Htaccess mod rewrite seo url setup












1















I have a site it was runing without seo, I changed links to seo urls.
I create seo links and save them in db.
and usaqe is : seo_url, all fine with php part but having problem with htaccess setup.
I read tons of articles and questions about htaccess setup, and after all I came to this solution which is not working correctly.



need some help espacially in Upanel pagination part. Upanel is a folder.



closest answer was that one :



RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^home/?$ index.php [NC,L]

RewriteRule ^contact/?$ contact.php [NC,L]

RewriteRule ^Upanel/?$ Upanel/account.php [NC,L]

RewriteRule ^Upanel/page/?$ Upanel/account.php?page=$1[L]

RewriteRule ^reset-password/?$ forgot.php [NC,L]

RewriteRule ^change-password/?$ resetpass.php [NC,L]

RewriteRule ^user/?$ login.php [NC,L]

RewriteRule ^search/?$ search.php [NC,L]

RewriteRule ^hr-search/?$ ik.php [NC,L]

RewriteRule ^sitemap/?$ rss.php [NC,L]

RewriteRule ^([a-zA-Z0-9_-]+)/?$ detail.php?p=$1 [NC,L]

RewriteRule ^category/([a-zA-Z0-9_-]+)/?$ categories.php?q=$1 [NC,L]


Thanks for helps










share|improve this question



























    1















    I have a site it was runing without seo, I changed links to seo urls.
    I create seo links and save them in db.
    and usaqe is : seo_url, all fine with php part but having problem with htaccess setup.
    I read tons of articles and questions about htaccess setup, and after all I came to this solution which is not working correctly.



    need some help espacially in Upanel pagination part. Upanel is a folder.



    closest answer was that one :



    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^home/?$ index.php [NC,L]

    RewriteRule ^contact/?$ contact.php [NC,L]

    RewriteRule ^Upanel/?$ Upanel/account.php [NC,L]

    RewriteRule ^Upanel/page/?$ Upanel/account.php?page=$1[L]

    RewriteRule ^reset-password/?$ forgot.php [NC,L]

    RewriteRule ^change-password/?$ resetpass.php [NC,L]

    RewriteRule ^user/?$ login.php [NC,L]

    RewriteRule ^search/?$ search.php [NC,L]

    RewriteRule ^hr-search/?$ ik.php [NC,L]

    RewriteRule ^sitemap/?$ rss.php [NC,L]

    RewriteRule ^([a-zA-Z0-9_-]+)/?$ detail.php?p=$1 [NC,L]

    RewriteRule ^category/([a-zA-Z0-9_-]+)/?$ categories.php?q=$1 [NC,L]


    Thanks for helps










    share|improve this question

























      1












      1








      1








      I have a site it was runing without seo, I changed links to seo urls.
      I create seo links and save them in db.
      and usaqe is : seo_url, all fine with php part but having problem with htaccess setup.
      I read tons of articles and questions about htaccess setup, and after all I came to this solution which is not working correctly.



      need some help espacially in Upanel pagination part. Upanel is a folder.



      closest answer was that one :



      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f

      RewriteRule ^home/?$ index.php [NC,L]

      RewriteRule ^contact/?$ contact.php [NC,L]

      RewriteRule ^Upanel/?$ Upanel/account.php [NC,L]

      RewriteRule ^Upanel/page/?$ Upanel/account.php?page=$1[L]

      RewriteRule ^reset-password/?$ forgot.php [NC,L]

      RewriteRule ^change-password/?$ resetpass.php [NC,L]

      RewriteRule ^user/?$ login.php [NC,L]

      RewriteRule ^search/?$ search.php [NC,L]

      RewriteRule ^hr-search/?$ ik.php [NC,L]

      RewriteRule ^sitemap/?$ rss.php [NC,L]

      RewriteRule ^([a-zA-Z0-9_-]+)/?$ detail.php?p=$1 [NC,L]

      RewriteRule ^category/([a-zA-Z0-9_-]+)/?$ categories.php?q=$1 [NC,L]


      Thanks for helps










      share|improve this question














      I have a site it was runing without seo, I changed links to seo urls.
      I create seo links and save them in db.
      and usaqe is : seo_url, all fine with php part but having problem with htaccess setup.
      I read tons of articles and questions about htaccess setup, and after all I came to this solution which is not working correctly.



      need some help espacially in Upanel pagination part. Upanel is a folder.



      closest answer was that one :



      RewriteEngine On
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteCond %{REQUEST_FILENAME} !-f

      RewriteRule ^home/?$ index.php [NC,L]

      RewriteRule ^contact/?$ contact.php [NC,L]

      RewriteRule ^Upanel/?$ Upanel/account.php [NC,L]

      RewriteRule ^Upanel/page/?$ Upanel/account.php?page=$1[L]

      RewriteRule ^reset-password/?$ forgot.php [NC,L]

      RewriteRule ^change-password/?$ resetpass.php [NC,L]

      RewriteRule ^user/?$ login.php [NC,L]

      RewriteRule ^search/?$ search.php [NC,L]

      RewriteRule ^hr-search/?$ ik.php [NC,L]

      RewriteRule ^sitemap/?$ rss.php [NC,L]

      RewriteRule ^([a-zA-Z0-9_-]+)/?$ detail.php?p=$1 [NC,L]

      RewriteRule ^category/([a-zA-Z0-9_-]+)/?$ categories.php?q=$1 [NC,L]


      Thanks for helps







      php .htaccess






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 6:52









      KareemKareem

      113




      113
























          1 Answer
          1






          active

          oldest

          votes


















          0














          For all your listed rules, Rewrite condition (RewriteCond) is not needed.



          read the comments in the example below.



          RewriteEngine On
          # ^home index.php :request "starts with home"(^home) redirected to index.php,
          # [NC,L] search is case insensitive(ie it also matches Home,hOme etc.
          # [L] stop processing after this rule.
          RewriteRule ^home index.php [NC, L]
          # ^Upanel/page/ request starts with Upanel/page/
          # (.*)$ "everything"(.*) after it "upto end"($) is stored in $1
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          just modified your rules.



          RewriteEngine On

          RewriteRule ^home/ index.php [NC,L]
          RewriteRule ^contact/ contact.php [NC,L]
          RewriteRule ^Upanel/$ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
          RewriteRule ^reset-password/ forgot.php [NC,L]
          RewriteRule ^change-password/ resetpass.php [NC,L]
          RewriteRule ^user/$ login.php [NC,L]
          RewriteRule ^search/$ search.php [NC,L]
          RewriteRule ^hr-search/$ ik.php [NC,L]
          RewriteRule ^sitemap/$ rss.php [NC,L]
          RewriteRule ^([a-zA-Z0-9_-]+)/ detail.php?p=$1 [NC,L]
          RewriteRule ^category/([a-zA-Z0-9_-]+) categories.php?q=$1 [NC,L]


          See this.



          RewriteRule ^Upanel/ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          here the second rewriteRule never work because every request which matches second condition also matched by first condition and L flag make sure it stops there at first condition. there for either of the following will work, choose with respect to your requirements.



          RewriteRule ^Upanel/$ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          OR



          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
          RewriteRule ^Upanel/ Upanel/account.php [NC,L]


          see rewrite rule flags and answrers for order of rewrite rules






          share|improve this answer
























          • thanks for the answer first , I tried your modified code, but getting error * requested file was not found on this server*. on all urls except detail.php, I am reading your post and trying combinations

            – Kareem
            Nov 21 '18 at 8:27











          • made it work after reading your comments carefully thank you so much, can't give you reputation yet sorry.

            – Kareem
            Nov 21 '18 at 8:51











          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%2f53406671%2fhtaccess-mod-rewrite-seo-url-setup%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














          For all your listed rules, Rewrite condition (RewriteCond) is not needed.



          read the comments in the example below.



          RewriteEngine On
          # ^home index.php :request "starts with home"(^home) redirected to index.php,
          # [NC,L] search is case insensitive(ie it also matches Home,hOme etc.
          # [L] stop processing after this rule.
          RewriteRule ^home index.php [NC, L]
          # ^Upanel/page/ request starts with Upanel/page/
          # (.*)$ "everything"(.*) after it "upto end"($) is stored in $1
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          just modified your rules.



          RewriteEngine On

          RewriteRule ^home/ index.php [NC,L]
          RewriteRule ^contact/ contact.php [NC,L]
          RewriteRule ^Upanel/$ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
          RewriteRule ^reset-password/ forgot.php [NC,L]
          RewriteRule ^change-password/ resetpass.php [NC,L]
          RewriteRule ^user/$ login.php [NC,L]
          RewriteRule ^search/$ search.php [NC,L]
          RewriteRule ^hr-search/$ ik.php [NC,L]
          RewriteRule ^sitemap/$ rss.php [NC,L]
          RewriteRule ^([a-zA-Z0-9_-]+)/ detail.php?p=$1 [NC,L]
          RewriteRule ^category/([a-zA-Z0-9_-]+) categories.php?q=$1 [NC,L]


          See this.



          RewriteRule ^Upanel/ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          here the second rewriteRule never work because every request which matches second condition also matched by first condition and L flag make sure it stops there at first condition. there for either of the following will work, choose with respect to your requirements.



          RewriteRule ^Upanel/$ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          OR



          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
          RewriteRule ^Upanel/ Upanel/account.php [NC,L]


          see rewrite rule flags and answrers for order of rewrite rules






          share|improve this answer
























          • thanks for the answer first , I tried your modified code, but getting error * requested file was not found on this server*. on all urls except detail.php, I am reading your post and trying combinations

            – Kareem
            Nov 21 '18 at 8:27











          • made it work after reading your comments carefully thank you so much, can't give you reputation yet sorry.

            – Kareem
            Nov 21 '18 at 8:51
















          0














          For all your listed rules, Rewrite condition (RewriteCond) is not needed.



          read the comments in the example below.



          RewriteEngine On
          # ^home index.php :request "starts with home"(^home) redirected to index.php,
          # [NC,L] search is case insensitive(ie it also matches Home,hOme etc.
          # [L] stop processing after this rule.
          RewriteRule ^home index.php [NC, L]
          # ^Upanel/page/ request starts with Upanel/page/
          # (.*)$ "everything"(.*) after it "upto end"($) is stored in $1
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          just modified your rules.



          RewriteEngine On

          RewriteRule ^home/ index.php [NC,L]
          RewriteRule ^contact/ contact.php [NC,L]
          RewriteRule ^Upanel/$ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
          RewriteRule ^reset-password/ forgot.php [NC,L]
          RewriteRule ^change-password/ resetpass.php [NC,L]
          RewriteRule ^user/$ login.php [NC,L]
          RewriteRule ^search/$ search.php [NC,L]
          RewriteRule ^hr-search/$ ik.php [NC,L]
          RewriteRule ^sitemap/$ rss.php [NC,L]
          RewriteRule ^([a-zA-Z0-9_-]+)/ detail.php?p=$1 [NC,L]
          RewriteRule ^category/([a-zA-Z0-9_-]+) categories.php?q=$1 [NC,L]


          See this.



          RewriteRule ^Upanel/ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          here the second rewriteRule never work because every request which matches second condition also matched by first condition and L flag make sure it stops there at first condition. there for either of the following will work, choose with respect to your requirements.



          RewriteRule ^Upanel/$ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          OR



          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
          RewriteRule ^Upanel/ Upanel/account.php [NC,L]


          see rewrite rule flags and answrers for order of rewrite rules






          share|improve this answer
























          • thanks for the answer first , I tried your modified code, but getting error * requested file was not found on this server*. on all urls except detail.php, I am reading your post and trying combinations

            – Kareem
            Nov 21 '18 at 8:27











          • made it work after reading your comments carefully thank you so much, can't give you reputation yet sorry.

            – Kareem
            Nov 21 '18 at 8:51














          0












          0








          0







          For all your listed rules, Rewrite condition (RewriteCond) is not needed.



          read the comments in the example below.



          RewriteEngine On
          # ^home index.php :request "starts with home"(^home) redirected to index.php,
          # [NC,L] search is case insensitive(ie it also matches Home,hOme etc.
          # [L] stop processing after this rule.
          RewriteRule ^home index.php [NC, L]
          # ^Upanel/page/ request starts with Upanel/page/
          # (.*)$ "everything"(.*) after it "upto end"($) is stored in $1
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          just modified your rules.



          RewriteEngine On

          RewriteRule ^home/ index.php [NC,L]
          RewriteRule ^contact/ contact.php [NC,L]
          RewriteRule ^Upanel/$ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
          RewriteRule ^reset-password/ forgot.php [NC,L]
          RewriteRule ^change-password/ resetpass.php [NC,L]
          RewriteRule ^user/$ login.php [NC,L]
          RewriteRule ^search/$ search.php [NC,L]
          RewriteRule ^hr-search/$ ik.php [NC,L]
          RewriteRule ^sitemap/$ rss.php [NC,L]
          RewriteRule ^([a-zA-Z0-9_-]+)/ detail.php?p=$1 [NC,L]
          RewriteRule ^category/([a-zA-Z0-9_-]+) categories.php?q=$1 [NC,L]


          See this.



          RewriteRule ^Upanel/ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          here the second rewriteRule never work because every request which matches second condition also matched by first condition and L flag make sure it stops there at first condition. there for either of the following will work, choose with respect to your requirements.



          RewriteRule ^Upanel/$ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          OR



          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
          RewriteRule ^Upanel/ Upanel/account.php [NC,L]


          see rewrite rule flags and answrers for order of rewrite rules






          share|improve this answer













          For all your listed rules, Rewrite condition (RewriteCond) is not needed.



          read the comments in the example below.



          RewriteEngine On
          # ^home index.php :request "starts with home"(^home) redirected to index.php,
          # [NC,L] search is case insensitive(ie it also matches Home,hOme etc.
          # [L] stop processing after this rule.
          RewriteRule ^home index.php [NC, L]
          # ^Upanel/page/ request starts with Upanel/page/
          # (.*)$ "everything"(.*) after it "upto end"($) is stored in $1
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          just modified your rules.



          RewriteEngine On

          RewriteRule ^home/ index.php [NC,L]
          RewriteRule ^contact/ contact.php [NC,L]
          RewriteRule ^Upanel/$ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
          RewriteRule ^reset-password/ forgot.php [NC,L]
          RewriteRule ^change-password/ resetpass.php [NC,L]
          RewriteRule ^user/$ login.php [NC,L]
          RewriteRule ^search/$ search.php [NC,L]
          RewriteRule ^hr-search/$ ik.php [NC,L]
          RewriteRule ^sitemap/$ rss.php [NC,L]
          RewriteRule ^([a-zA-Z0-9_-]+)/ detail.php?p=$1 [NC,L]
          RewriteRule ^category/([a-zA-Z0-9_-]+) categories.php?q=$1 [NC,L]


          See this.



          RewriteRule ^Upanel/ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          here the second rewriteRule never work because every request which matches second condition also matched by first condition and L flag make sure it stops there at first condition. there for either of the following will work, choose with respect to your requirements.



          RewriteRule ^Upanel/$ Upanel/account.php [NC,L]
          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]


          OR



          RewriteRule ^Upanel/page/(.*)$ Upanel/account.php?page=$1 [L]
          RewriteRule ^Upanel/ Upanel/account.php [NC,L]


          see rewrite rule flags and answrers for order of rewrite rules







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 21 '18 at 7:57









          BobanBoban

          314




          314













          • thanks for the answer first , I tried your modified code, but getting error * requested file was not found on this server*. on all urls except detail.php, I am reading your post and trying combinations

            – Kareem
            Nov 21 '18 at 8:27











          • made it work after reading your comments carefully thank you so much, can't give you reputation yet sorry.

            – Kareem
            Nov 21 '18 at 8:51



















          • thanks for the answer first , I tried your modified code, but getting error * requested file was not found on this server*. on all urls except detail.php, I am reading your post and trying combinations

            – Kareem
            Nov 21 '18 at 8:27











          • made it work after reading your comments carefully thank you so much, can't give you reputation yet sorry.

            – Kareem
            Nov 21 '18 at 8:51

















          thanks for the answer first , I tried your modified code, but getting error * requested file was not found on this server*. on all urls except detail.php, I am reading your post and trying combinations

          – Kareem
          Nov 21 '18 at 8:27





          thanks for the answer first , I tried your modified code, but getting error * requested file was not found on this server*. on all urls except detail.php, I am reading your post and trying combinations

          – Kareem
          Nov 21 '18 at 8:27













          made it work after reading your comments carefully thank you so much, can't give you reputation yet sorry.

          – Kareem
          Nov 21 '18 at 8:51





          made it work after reading your comments carefully thank you so much, can't give you reputation yet sorry.

          – Kareem
          Nov 21 '18 at 8:51




















          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%2f53406671%2fhtaccess-mod-rewrite-seo-url-setup%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

          How to change which sound is reproduced for terminal bell?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Can I use Tabulator js library in my java Spring + Thymeleaf project?