1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Problem with url rewrite

Discussion in 'PHP' started by mitchbuch, Nov 17, 2009.

  1. #1
    I have a problem with url re-write.

    My host does not support the "DirectoryIndex"

    My current .htaccess file looks like this:

    DirectoryIndex index.php
    
    RewriteEngine on
    RewriteRule ^cat/([0-9]+)?/([0-9a-zA-Z'?-]+)/p([0-9]+) index.php?task=category&id=$1&name=$2&page=$3 [L]
    RewriteRule ^cat/([0-9]+)?/([0-9a-zA-Z'?-]+)/([0-9a-zA-Z?-]+)/p([0-9]+) index.php?task=category&id=$1&name=$2&sortby=$3&page=$4 [L]
    Code (markup):
    Is there anyway to get the same result without using DirectoryIndex ?
     
    mitchbuch, Nov 17, 2009 IP
  2. mitchbuch

    mitchbuch Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #2
    I have done some testing, and .e.g WordPress work with permlink on the server.. So mod-rewrite should work at least.

    But how does WordPRess rewrite?? Anyone know? I have tried to figure out.
     
    mitchbuch, Nov 17, 2009 IP
  3. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #3
    Try this, maybe it helps.
    
    RewriteEngine on
    RewriteBase /
    RewriteRule ^cat/([0-9]+)?/([0-9a-zA-Z'?-]+)/p([0-9]+) /index.php?task=category&id=$1&name=$2&page=$3 [L]
    RewriteRule ^cat/([0-9]+)?/([0-9a-zA-Z'?-]+)/([0-9a-zA-Z?-]+)/p([0-9]+) /index.php?task=category&id=$1&name=$2&sortby=$3&page=$4 [L]
    
    Code (markup):
     
    AsHinE, Nov 17, 2009 IP
  4. Ascendancy

    Ascendancy Active Member

    Messages:
    1,721
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    90
    #4
    Second this question, Wordpress is very mysterious with how they can easily allow you to customize your URL redirects. Can anybody provide insight into how this is possible?
     
    Ascendancy, Nov 17, 2009 IP
  5. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #5
    I guess it's all about parsing $_SERVER['REQUEST_URI'] and proccesing it.
     
    AsHinE, Nov 17, 2009 IP
  6. szalinski

    szalinski Peon

    Messages:
    341
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The default DirectoryIndex is index.php anyway so why would you even need it in the first place?
     
    szalinski, Nov 20, 2009 IP
    Toopac likes this.
  7. Toopac

    Toopac Peon

    Messages:
    4,451
    Likes Received:
    166
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yup, and index.(file) should be default.
     
    Toopac, Nov 23, 2009 IP