Mod Rewrite - Proven Way?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sdjl
    Senior Member
    • Mar 2004
    • 502

    Mod Rewrite - Proven Way?

    Is there a proven way for using Mod Rewrite with the current server configurations here at Dathorn?

    I've tried using the following code:
    Code:
    # Create internal redirects for portfolio
    RewriteEngine On
    RewriteRule ^/portfolio/(.*)\.php /portfolio.php?news_id=$1
    RewriteRule ^/cv/(.*)\.php /cv.php?cv_id=$1
    RewriteRule ^/contact/(.*)\.php /contact.php?news_id=$1
    As you could probably guess though, this give me an error. I get returned to me a nice 404 error, which is unusual considering the documents are all in place.

    Does anyone use a similar Rewrite code sample that actually works with the Dathorn server setup?
    I'm on cPanel 20 is that's of any use.

    Thanks,

    David
    -----
    Do you fear the obsolescence of the metanarrative apparatus of legitimation?
  • sdjl
    Senior Member
    • Mar 2004
    • 502

    #2
    So the above mod_rewrite rules may not work here on Dathorn, but the following should:

    Code:
    # Create internal redirects for portfolio
    RewriteEngine On
    RewriteRule ^portfolio/(.*)\.php /portfolio.php?news_id=$1
    RewriteRule ^cv/(.*)\.php /cv.php?cv_id=$1
    RewriteRule ^contact/(.*)\.php /contact.php?news_id=$1
    However, if you request: url.com/portfolio you get a 404
    Requesting: url.com/portfolio/ doesn't give you a 404

    David
    -----
    Do you fear the obsolescence of the metanarrative apparatus of legitimation?

    Comment

    • -Oz-
      Senior Member
      • Mar 2004
      • 545

      #3
      That's easy.
      Code:
      RewriteRule ^portfolio[b]/[/b](.*)\.php /portfolio.php?news_id=$1
      can be converted to:
      Code:
      RewriteRule ^portfolio(.*)\.php /portfolio.php?news_id=$1
      That will make it so you don't need the ending slash.
      Dan Blomberg

      Comment

      • sdjl
        Senior Member
        • Mar 2004
        • 502

        #4
        You'd think that would work, but unfortunately it doesn't.
        If i use your example, going to either url.com/portfolio or url.com/portfolio i get a 404.
        If i then got to url.com/portfolio/1.php i get an internal server error.

        This mod_rewrite stuff is good fun :-D

        David
        -----
        Do you fear the obsolescence of the metanarrative apparatus of legitimation?

        Comment

        • Buddha
          Senior Member
          • Mar 2004
          • 825

          #5
          I'm just going to plop this in here:

          Download URL shortener/redirector for free. Create multiple shortened URLs like www.mysite.net/go/?newsarticle which link to other URLs! With a small change to the .htaccess files (if it is running on Apache), the shortened urls can look however you like.


          Wonder if it works?
          "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

          Comment

          • sdjl
            Senior Member
            • Mar 2004
            • 502

            #6
            Wow that files big!
            -----
            Do you fear the obsolescence of the metanarrative apparatus of legitimation?

            Comment

            Working...