.htaccess file is not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • waqasahmed996
    New Member
    • Jun 2008
    • 160

    .htaccess file is not working

    Hi to all
    I m looking for some help. i want to do url rewritting. i write code e.g
    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule index/show/(.*)/cat/(.*)/ index.php?show=$1&cat=$2
    RewriteRule index/show/(.*)/cat/(.*) index.php?show=$1&cat=$2
    1)On local host its give an error "Internal Server Error". same error occurred even when i wrote just first two lines of above code.

    2)On live site it not give any error but its not working at all. In fact there is no effect of writing above code.

    is there any problem in php settings. Please send me some solution. I tried hard but did't find any solution
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hey.

    Have you checked the error log to see what is going on?
    By default, the file is located at:
    "C:\Program Files\Apache Software Foundation\Apac he2.2\logs\erro r.log". (On Windows, that is)

    On Linux they can be in different places. I'd start by looking at the /var/log directory.

    Comment

    • waqasahmed996
      New Member
      • Jun 2008
      • 160

      #3
      Thanks Atli for your kind reply

      i opened error.log but i dont know how to check from error.log that what is going on

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Check the latest entries. When you get an internal server error the actual error is written into those logs.

        You can post them here (not all of them, just those that happened at the time your internal server error happened) and we can help you figure them out.

        Comment

        • waqasahmed996
          New Member
          • Jun 2008
          • 160

          #5
          Thanks Atil for your reply. Atil i dont think so that any thing happened in error log due to that error. i am facing this error rite now but last few lines of error log are

          Code:
          [Wed Dec 10 09:45:25 2008] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico
          [Wed Dec 10 09:49:45 2008] [notice] Parent: Received shutdown signal -- Shutting down the server.
          [Wed Dec 10 09:49:45 2008] [notice] Child 3912: Exit event signaled. Child process is ending.
          [Wed Dec 10 09:49:46 2008] [notice] Child 3912: Released the start mutex
          [Wed Dec 10 09:49:49 2008] [notice] Child 3912: All worker threads have exited.
          [Wed Dec 10 09:49:49 2008] [notice] Child 3912: Child process is exiting
          [Wed Dec 10 09:49:49 2008] [notice] Parent: Child process exited successfully.
          i also want to mention that i am using wamp and this file exist in
          C:\wamp\bin\apa che\Apache2.2.1 1\logs

          Comment

          • waqasahmed996
            New Member
            • Jun 2008
            • 160

            #6
            Any other reason for that problem?

            Comment

            • Atli
              Recognized Expert Expert
              • Nov 2006
              • 5062

              #7
              That's odd. The error messages should be in the log. Could be that XAMPP does something differently than a typical Apache installation.

              Anyhow. Are you sure mod_rewrite is installed on the server, and that it is active?

              Try wrapping the RewriteRule stuff in IfModule tags.
              [code=htaccess]<IfModule mod_rewrite.c>
              RewriteEngine On
              RewriteRule index/show/(.*)/cat/(.*)/? index.php?show= $1&cat=$2
              </IfModule>[/code]
              This will make sure the modules is active before trying to use it. If the module is not active, your rewrite rules will simply be ignored. Your site will work, but the rewrite rules will not.

              P.S.
              I combined your two rules into one in that example. If you trail any character in a regular expression with a question-mark it becomes optional.

              Comment

              • waqasahmed996
                New Member
                • Jun 2008
                • 160

                #8
                Thanks Atli,
                you are right mod rewrite is not installed. i came to know this by using your code in which you use if condition
                please tell me what is next step now. how i ll install it

                Comment

                • Atli
                  Recognized Expert Expert
                  • Nov 2006
                  • 5062

                  #9
                  I have never really used XAMPP myself so I wouldn't know, but Google seems to have a lot of info on the subject.

                  Comment

                  • waqasahmed996
                    New Member
                    • Jun 2008
                    • 160

                    #10
                    Thanks Atil. You really help me

                    Comment

                    • Atli
                      Recognized Expert Expert
                      • Nov 2006
                      • 5062

                      #11
                      Your welcome. Glad I could help :)

                      One last thing I should point out though.

                      Your RewriteRule. It is meant to allow you to use this URL:
                      - index/show/zzz/cat/yyy/
                      instead of this URL:
                      - index.php?show= zzz1&cat=yyy

                      I should point out that search engines would most likely have an easier time understanding the original one, with the query-string. There, they can match up the values with their respective keys, whereas in your new version they can't.

                      In fact, you may well be better of leaving it unaltered.
                      If not, I still suggest you change the structure of the new URL. If you explain what the values - show and cat - mean and I can make a suggestion.

                      See these fore more details:
                      And you can probably find a lot more of those via Google.

                      Comment

                      • waqasahmed996
                        New Member
                        • Jun 2008
                        • 160

                        #12
                        excellent point
                        i am doing this to make site SEO friendly
                        and i also read and heard from many people to use urls like
                        index/show/zzz/cat/yyy/
                        to make them SEO friendly
                        Atli what about if we use urls like
                        index-show-zzz1-cat-yyy.htm
                        by using url rewriting instead index/show/zzz/cat/yyy/
                        will it be helpful to make site SEO friendly??

                        Comment

                        • Atli
                          Recognized Expert Expert
                          • Nov 2006
                          • 5062

                          #13
                          No, not really. Leaving it like "index.php?show =zzz&cat=yyy" would most likely be more SEO friendly. - It is easier for a computer to understand that zzz is the value of show, and that yyy is the value of cat when you use this basic format. - When you set them up side-by-side in a directory hierarchy - or even worse; as a single file name -, that becomes harder to determine. The key and the value become as two separate, equal-value values, when in fact they should be a key-value pair.

                          It is best to just set the URL up in a way that would be most easily understood by a human. In your case, assuming show represents an action (e.g. "list" or "details") that is to be taken on a given category, something like this may be a good idea:
                          • example.com/categories/zzz.php?category=yyy

                          That might turn into something like:
                          • example.com/categories/list.php?catego ry=name-of-category
                          • example.com/categories/details.php?cat egory=name-of-category
                          • example.com/categories/details.php?cat egory-id=1234

                          There, from the point of view of an outsider, each of your show parameters is a different PHP file, inside a "categories " directory, which takes a cat (or category) as a parameter. Pretty easy to understand both by a human visitor and by a bot.

                          P.S.
                          You should note that most of the SEO tricks that you see floating around are mostly bogus, or at least have very limited effectiveness.
                          A few common SEO tricks that people waste way to much time on:
                          • Pretty-URLs. (mod_rewrite)
                            In some cases this may have it's uses, but for the most part, use this to improve things for your human visitors, not the bots.
                          • Meta description/keywords.
                            This was exploited so much in the past that it is hardly worth using today. You should of course include the description (Google might display it with the link in the search results), and adding a few keywords is fine, but don't think either will improve your SEO rating.
                          • Keyword spamming.
                            This was also exploited. People crammed keywords all over the page to score high for them in the search results. - Today Google is more likely to penalize you for this. - You should of course include your keywords in your text, but write it for a human not for a bot.
                          • Bold/strong text
                            Again, exploited in the past. Bold words are traditionally more important than others, and as such, weigh more on the search results. But overusing it will just hurt you. - Use it as it was intended: to emphasize words to human readers, not to bots.
                          • Link-exchange
                            This *can* be helpful if used responsibly, but people are rarely responsible. - It is far more effective to write good content and "naturally" link to other pages with good content. They, in turn, may become aware of your site and link back to your content.
                          • ... spamming
                            An obvious way to get black-listed; banned from even appearing in search results at all. - We sometimes see it on forums like these. People signing up solely to post links to their new site, promoting their new business site. - We promptly delete stuff like that and submit it to be black-listed. - Most forum systems do.

                          Don't get me wrong, some of these may have limited usefulness, but compared to good content, this is close to irrelevant. - The best way to get your site noticed is to have good content; content that people will want to read and link to. A single link to your content is worth more than all of these SEO tricks combined. - Spend more time creating good content; less time on SEO. Focus on your human visitors, not the bots.

                          Comment

                          Working...