.htaccess rewrite issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Publisher Bucks
    Confirmed User
    • Oct 2018
    • 1337

    #1

    Tech .htaccess rewrite issue

    Can anyone who knows about .htaccess tell me why this is giving me a 500 error?

    Its supposed to be re-writing the URLs so they are SEO friendly

    RewriteRule ^link-name$ link.php?id=link-name [L]
    RewriteCond %{THE_REQUEST} ^[A-Z][3,9] /link.php?id=243 HTTP/
    RewriteRule ^link.php$ https://www.domain.com/links/link? [R=301,L]
    I've placed it as .htaccess in the /links/ directory and the domain root and it still kicks out a 500 error.

    When its in the /links/ directory it gives me an error when I click on one of the urls.
    When its in the domain root it wont even load the page before kicking out a 500 error.

    According to several Google results, this *should* be working perfectly
    Extreme Link List - v1.0
  • k0nr4d
    Confirmed User
    • Aug 2006
    • 9231

    #2
    That's all so wrong that I don't even know where to start, because I can't figure out what it is you are trying to do from looking at those 3 lines
    Mechanical Bunny Media
    Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

    Comment

    • Publisher Bucks
      Confirmed User
      • Oct 2018
      • 1337

      #3
      It’s supposed to rewrite from link.php?id=XX

      To /links/some-link-name

      There’s a ton of sites including Sitepoint threads that say this should work to achieve that.
      Extreme Link List - v1.0

      Comment

      • ravo
        Confirmed User
        • Jun 2001
        • 5461

        #4
        I'm far from an .htaccess expert, but look at;

        https://stackoverflow.com/questions/...o-friendly-url
        AdultAdBroker - Buy and Sell Your Flat Rate Banners, Links, Tabs, Pops, Email Clicks and Members' Area Traffic - updated May 2026

        Comment

        • k0nr4d
          Confirmed User
          • Aug 2006
          • 9231

          #5
          Originally posted by Publisher Bucks
          It’s supposed to rewrite from link.php?id=XX

          To /links/some-link-name

          There’s a ton of sites including Sitepoint threads that say this should work to achieve that.
          RewriteEngine On
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule ^(.*)$ links.php?id=$1 [QSA,L]
          Mechanical Bunny Media
          Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

          Comment

          • sarettah
            see you later, I'm gone
            • Oct 2002
            • 14330

            #6
            Originally posted by Publisher Bucks
            It’s supposed to rewrite from link.php?id=XX

            To /links/some-link-name

            There’s a ton of sites including Sitepoint threads that say this should work to achieve that.
            That looks bass-ackward to me.

            Foe SEO friendly you would have .htacess that rewrites domain/links/link_name to domain/links.php?....

            Not the other way around.

            .
            All cookies cleared!

            Comment

            • fuzebox
              making it rain
              • Oct 2003
              • 22353

              #7
              Originally posted by Publisher Bucks
              There’s a ton of sites including Sitepoint threads that say this should work to achieve that.

              Comment

              • Publisher Bucks
                Confirmed User
                • Oct 2018
                • 1337

                #8
                Originally posted by k0nr4d
                RewriteEngine On
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ links.php?id=$1 [QSA,L]
                k0nr4d,

                That doesnt do anything when I put it in .htaccess, I was using that originally, then did a search for alternate ways to achieve what I wanted to happen :/
                Extreme Link List - v1.0

                Comment

                • Publisher Bucks
                  Confirmed User
                  • Oct 2018
                  • 1337

                  #9
                  Originally posted by sarettah
                  That looks bass-ackward to me.

                  Foe SEO friendly you would have .htacess that rewrites domain/links/link_name to domain/links.php?....

                  Not the other way around.

                  .
                  I was always under the impression that turning link.php?id=XX to /links/link/-link-name-here/ was a much better option for SEO purposes?
                  Extreme Link List - v1.0

                  Comment

                  • Publisher Bucks
                    Confirmed User
                    • Oct 2018
                    • 1337

                    #10
                    Originally posted by ravo
                    I'm far from an .htaccess expert, but look at;

                    https://stackoverflow.com/questions/...o-friendly-url
                    Thats actually one of the methods I tried, it works (sort of) but displays the full /root/usr/domain.com/links/link-name-here in the browser.

                    When editing the rewrite slightly, the most I could get it to do was /links/link/32 (link id number not the title of the link itself).

                    It also just redirects to my 404 catchall pages content, not the link ids page content :/
                    Extreme Link List - v1.0

                    Comment

                    • zijlstravideo
                      Confirmed User
                      • Sep 2013
                      • 806

                      #11
                      Originally posted by Publisher Bucks
                      Thats actually one of the methods I tried, it works (sort of) but displays the full /root/usr/domain.com/links/link-name-here in the browser.

                      When editing the rewrite slightly, the most I could get it to do was /links/link/32 (link id number not the title of the link itself).

                      It also just redirects to my 404 catchall pages content, not the link ids page content :/
                      But why do you need to take the ID number as a GET query exactly? Why not take the url slug as a query directly? Sounds a lot more straight forward and easier to setup in such way...

                      For example, just make "domain.com/links.php?id=big-boobies" redirect to "domain.com/links/link/big-boobies". You can skip the whole ID thing, you can get the matching ID number using the slug as well (just look it up from your database).

                      Or make it work with both the slug and the ID number as query... then let your php code do the magic. If the GET parameter is an integer, connect to your database, find the matching slug first and then go ahead and force redirect to domain.com/links/rick-james-bitch...
                      Contact: email

                      Comment

                      Working...