rewriting "server.com/articles/order:date" works, "server.com/order:date" NOT

Discussion in 'Apache' started by martinno, May 15, 2007.

  1. #1
    i have a quite interesting problem.

    i use mod_rewrite to have "nice and cool urls" on my server. everything works fine. i decided to add new functionality:
    <parameter-name>:<parameter-value> (e.g. order:date for order by date)

    when i call www.server.com/articles/order:date apache displays articles page with ordered articles by date, so rewriting works properly. but when i try to call www.server.com/order:date to order articles on title page, apache does "nothing" - apache does not rewrite the url and it try to display page /order:date:

    Forbidden
    You don't have permission to access /order:date on this server.


    (but if i replace : delimiter by ~ or ! or @ (and some other signs), rewriting works ok also for www.server.com/order~date. rewriting also does not worl for | delimiter.)

    i have really no idea what's going wrong. any suggestions?
     
    martinno, May 15, 2007 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Forget :. Use - if you want it as search engine friendly as you can get it.
     
    Nintendo, May 15, 2007 IP
  3. martinno

    martinno Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks for reply, Nintendo.

    so, it's really not possible to use : as i want? why www.server.com/articles/order:date works and www.server.com/order:date does not?

    i think, there is not problem in rewriting rules, because when i call link www.server.com/order:date only access.log file is modified and rewrite.log and error.log files are not touched by apache. when i call www.server.com/articles/order:date, there is possible to see new records in access.log and rewrite.log logs.

    when i use : or | as delimiter signs, link www.server.com/order:date is not rewritten. but when i use e.g. ~ or @ or ! it works ok. that's the second reason why i think it's not due my rewrite rules.

    so, can you explain me it to make my apache knowledges deeper? thanks in advance
     
    martinno, May 16, 2007 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    Post your .htaccess codes. If this is to make the search engines like you, you'll use - .
     
    Nintendo, May 16, 2007 IP
  5. reyotech

    reyotech Peon

    Messages:
    102
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hey Nintendo,

    any more tips for making it SEO friendly?
     
    reyotech, May 17, 2007 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #6
    Use URLs that look like static URLs.
     
    Nintendo, May 17, 2007 IP
  7. martinno

    martinno Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Nintendo, here is my .htaccess:

    RewriteCond %{SCRIPT_FILENAME} !/index\.php
    RewriteCond %{REQUEST_URI} !/.+\..+$
    RewriteCond %{REQUEST_URI} !/$
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule (.*) http://%{HTTP_HOST}/$1/ [L,QSA]

    RewriteCond %{SCRIPT_FILENAME} !/index\.php
    RewriteRule ^(([a-z]{2})(/))?(.*)$ index.php?p1=$2&p2=$4 [NC,L,QSA]



    in your answer to reyotech you wrote to use URLs that look like static URLs. this means use www.server.com/articles/article-1 or www.server.com/articles/article-1.html ?
     
    martinno, May 18, 2007 IP
  8. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #8
    Both are just as good.

    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)/([^.]+)\.html$ index.php?p1=$1&p2=$2 [L]
    RewriteRule ^articles/([^.]+)/([^.]+)\.html$ articles/index.php?p1=$1&p2=$2 [L]

    domain.com/index.php?p1=order&p2=date.htm
    to
    domain.com/order/date.html

    the second code is if you have them in the articles directory.
     
    Nintendo, May 18, 2007 IP
  9. martinno

    martinno Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Nintendo, thanks for your reply and opinion, but my rewrite rules in .htaccess work properly, so i don't need any help in there. i just need to know the reason of non-rewriting the www.server.com/order:date url...
     
    martinno, May 20, 2007 IP
  10. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #10
    I'm guessing that's one of the characters that requires a RewriteCond for it to work.
     
    Nintendo, May 21, 2007 IP
  11. martinno

    martinno Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    i tried to write a RewriteCond, but without success... any idea, how to do it?
     
    martinno, May 23, 2007 IP
  12. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #12
    Use -, something that does work AND is search engine friendly.
     
    Nintendo, May 23, 2007 IP
  13. martinno

    martinno Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    seems, i will have to. anyway, thanks for help Nintendo
     
    martinno, May 24, 2007 IP