Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question complex htaccess?

    I have a htaccess rule which says:

    RewriteRule ^([0-9-]+)/?$ /card.php?cid=$1 [L]
    RewriteRule ^([0-9]+)/(.*)?$ card.php?cid=$1 [L]

    So right now i'm using this on syntax:
    http://www.mywebsite.com/1200/what-ever-i-want

    The thing is that i want to add more data so that card.php will use on the following syntax:

    http://www.mywebsite.com/1200/what-e...t/myvalue=3000

    on my card.php i want to fetch myvalue (using $_GET) but i cant since of the current htaccess rule that i'm using. is there any way of expanding it? something like:
    RewriteRule ^([0-9-]+)/?$ /card.php?cid=$1&$3 [L]

    ?

    Lior.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    How about
    Code:
    RewriteRule ^([0-9]+)/(.*)$ card.php?cid=$1&rest=$2 [L]
    and then process(slice) the $_GET['rest'] from the PHP side to get the required values?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    New Coder
    Join Date
    Jun 2008
    Posts
    19
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question

    Nope....

    I'm not sure you got me right.

    I want my url to look like this (ill give couple of examples):

    Example 1:
    http://www.mywebsite.com/1200/whatev...1=hi&note2=bye

    result: myfile.php?id=1200&note1=hi&note2=bye

    Example 2:
    http://www.mywebsite.com/1300/whatev...rue&master=yes

    result: myfile.php?id=1300&logged=true&master=yes


    it just drops the SEO words and uses all the other information.

    is that possible in htaccess?

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,801
    Thanks
    160
    Thanked 2,216 Times in 2,203 Posts
    Blog Entries
    1
    I'm not sure you got me right.
    I think I got you. What I'm trying to say is, with that rule(in my above post), you could obtain a long string in the $_GET['rest'] variable, which would be like
    Code:
    what-ever-i-want/myvalue=3000
    for a request of
    Code:
    /1200/what-ever-i-want/myvalue=3000
    Now you may slice this large string with some regexp in PHP, and there by reduce the complexity of your htaccess rule(which is working well now for your initial requirement)

    (There must be some other way, but I'm not an expert with this )
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •