strange .htaccess issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • freecartoonporn
    Confirmed User
    • Jan 2012
    • 7683

    #1

    strange .htaccess issue

    i am trying to rewrite urls on WAMP using .htaccess

    i want this

    Code:
    www.example.com/item/1234
    to redirect to this

    Code:
    www.example.com/item.php?id=1234
    so i have this in my .htaccess

    Code:
    RewriteEngine On
    
    RewriteRule ^item/([0-9]+)$ item.php?id=$1  [L]
    but now all internal links are prefixed with /item/

    this

    Code:
    <link rel="stylesheet" href="css/style.css">
    becomes this

    Code:
    <link rel="stylesheet" href="item/css/style.css">
    this is the first time i am having this kind of issue.,
    i have used same config in nginx and it used to work fine on lemp.

    but on wamp its screwing all the relative links.

    what is wrong ?


    i know i can define base url in html, but i want to know what is messing this and why now ?

    is it wamp ?


    Thanks for your time.
    SSD Cloud Server, VPS Server, Simple Cloud Hosting | DigitalOcean
  • NatalieK
    Natalie K
    • Apr 2010
    • 20114

    #2
    If correct, you´re trying to make sure your concealing the directory "item" by opening page item.php...

    why not just add page index.php in this directory, thus it always opens when going to this directory & here you can just redirect index.php to item.php
    My official site / Custom vids / Make money links / First time girls
    Email: [email protected] - "Converting traffic into income since 2005"

    Comment

    • redwhiteandblue
      Bollocks
      • Jun 2007
      • 2793

      #3
      Because he probably doesn't want query strings in his URLs, doesn't want to have to physically create the directory and doesn't want to redirect the browser at all?

      But i don't know anything about using htaccess on WAMP so I can't help. I wouldn't be surprised if the regex is totally different to Linux.
      Interserver unmanaged AMD Ryzen servers from $73.00

      Comment

      • NatalieK
        Natalie K
        • Apr 2010
        • 20114

        #4
        Originally posted by redwhiteandblue
        Because he probably doesn't want query strings in his URLs, doesn't want to have to physically create the directory and doesn't want to redirect the browser at all?

        But i don't know anything about using htaccess on WAMP so I can't help. I wouldn't be surprised if the regex is totally different to Linux.
        true dat.

        if it´s not possible, then the simple index.php and redirect is an easy option though
        My official site / Custom vids / Make money links / First time girls
        Email: [email protected] - "Converting traffic into income since 2005"

        Comment

        • k0nr4d
          Confirmed User
          • Aug 2006
          • 9231

          #5
          Originally posted by freecartoonporn
          i am trying to rewrite urls on WAMP using .htaccess

          i want this

          Code:
          www.example.com/item/1234
          to redirect to this

          Code:
          www.example.com/item.php?id=1234
          so i have this in my .htaccess

          Code:
          RewriteEngine On
          
          RewriteRule ^item/([0-9]+)$ item.php?id=$1  [L]
          but now all internal links are prefixed with /item/

          this

          Code:
          <link rel="stylesheet" href="css/style.css">
          becomes this

          Code:
          <link rel="stylesheet" href="item/css/style.css">
          this is the first time i am having this kind of issue.,
          i have used same config in nginx and it used to work fine on lemp.

          but on wamp its screwing all the relative links.

          what is wrong ?


          i know i can define base url in html, but i want to know what is messing this and why now ?

          is it wamp ?


          Thanks for your time.
          mod_negotiation - Apache HTTP Server Version 2.4
          Try disabling this, you probably have it on.
          Mechanical Bunny Media
          Mechbunny Tube Script | Mechbunny Webcam Aggregator Script | Custom Web Development

          Comment

          • freecartoonporn
            Confirmed User
            • Jan 2012
            • 7683

            #6
            Originally posted by k0nr4d
            mod_negotiation - Apache HTTP Server Version 2.4
            Try disabling this, you probably have it on.
            still nope.


            Code:
            Options -MultiViews
            RewriteEngine On
            RewriteBase /
            RewriteRule ^item/([0-9]+)$ item.php?id=$1  [L]
            SSD Cloud Server, VPS Server, Simple Cloud Hosting | DigitalOcean

            Comment

            • zerovic
              Confirmed User
              • Apr 2010
              • 1116

              #7
              Hey man,

              simply change the way you include your css file

              instead of using this

              <link rel="stylesheet" href="css/style.css">

              add it like this, with a leading slash

              <link rel="stylesheet" href="/css/style.css">

              if you use it without the leading slash, it will use the current url displayed in the browser.. if you add the leading slash, it will use the root domain

              if you still have troubles with it, add this to your .htaccess before the RewriteEngine On command

              RewriteRule ^css - [L,NC]

              this will completely ignore the css directory from any rewrite rule

              ps. tested it, it works

              if you can't make it work, feel free to contact me

              cheers,
              z
              php, html, jquery, javascript, wordpress - contact me at contact at zerovic.com

              Comment

              • freecartoonporn
                Confirmed User
                • Jan 2012
                • 7683

                #8
                Originally posted by zerovic
                Hey man,

                simply change the way you include your css file

                instead of using this

                <link rel="stylesheet" href="css/style.css">

                add it like this, with a leading slash

                <link rel="stylesheet" href="/css/style.css">

                if you use it without the leading slash, it will use the current url displayed in the browser.. if you add the leading slash, it will use the root domain

                if you still have troubles with it, add this to your .htaccess before the RewriteEngine On command

                RewriteRule ^css - [L,NC]

                this will completely ignore the css directory from any rewrite rule

                ps. tested it, it works

                if you can't make it work, feel free to contact me

                cheers,
                z
                this solved my issue.,
                Thank you.
                SSD Cloud Server, VPS Server, Simple Cloud Hosting | DigitalOcean

                Comment

                • Bladewire
                  StraightBro
                  • Aug 2003
                  • 56228

                  #9
                  ↑↑↑ Awesome!


                  Skype: CallTomNow

                  Comment

                  Working...