This discussion is locked
Achilleus

Q: How to get .htaccess URL rewriting working with the preinstalled apache2?

I've tried and tried to get this to work. I'm switching from windows to this macbook, and for the life of me, I can't get my .htaccess file to work with the URL rewriting. It's like the server isn't even recognizing that it's there. This is what I got in the .htaccess:

RewriteEngine on
RewriteRule ^games/$ index\.php\?action\=games
RewriteRule ^games$ index\.php\?action\=games
RewriteRule ^events/$ index\.php\?action\=events
RewriteRule ^events$ index\.php\?action\=events
RewriteRule ^downloads/$ index\.php\?action\=downloads
RewriteRule ^downloads$ index\.php\?action\=downloads
RewriteRule ^support/$ index\.php\?action\=support
RewriteRule ^support$ index\.php\?action\=support
RewriteRule ^blogs/$ wordpress/
RewriteRule ^blogs$ wordpress/

By all means it should be working, save for the fact that it's not even being read by Apache! In /private/etc/apache2/httpd.conf I edited every instance of AllowOverride None and changed it to AllowOverride All and it still will not work! I also went to /private/etc/apache2/users/achilleus/.conf and did the same in that file as well. For the life of me, when I go to http://localhost/index.php?action=games it works but when I go to http://localhost/games/ it refuses to cooperate. I looked in the error log for apache and it doesn't list anything, neither does the access log. I've been on Google for hours and I still can't find anything.

Can somebody please tell me how to enable the use of .htaccess files in a brand new installation of Leopard? I formatted this thing yesterday and ran all the updates.

MacBook, Mac OS X (10.5.4), switching from windows xp pro

Posted on Jul 29, 2008 11:19 AM

Close

Q: How to get .htaccess URL rewriting working with the preinstalled apache2?

  • All replies
  • Helpful answers

Previous Page 2 of 3 last Next
  • by Achilleus,

    Achilleus Achilleus Jul 29, 2008 3:04 PM in response to orangekay
    Level 1 (0 points)
    Jul 29, 2008 3:04 PM in response to orangekay
    I had a feeling there was an easier way to take care of having a slash or not at the end of the URL lol. But this still does not take care of the trailing slash that it's adding at the end of my files.
  • by Achilleus,

    Achilleus Achilleus Jul 29, 2008 3:11 PM in response to Achilleus
    Level 1 (0 points)
    Jul 29, 2008 3:11 PM in response to Achilleus
    RewriteEngine on
    RewriteRule ^games(/)?$ games\.html
    #RewriteRule ^games(/)?$ index\.php\?action\=games
    #RewriteRule ^events(/)?$ index\.php\?action\=events
    #RewriteRule ^downloads(/)?$ index\.php\?action\=downloads
    #RewriteRule ^support(/)?$ index\.php\?action\=support
    #RewriteRule ^blogs(/)?$ wordpress/

    That's my new .htaccess file. I have all the php files commented out until we can figure out why it's adding a trailing slash at the end of games.html
  • by orangekay,

    orangekay orangekay Jul 29, 2008 3:19 PM in response to Achilleus
    Level 5 (4,085 points)
    Jul 29, 2008 3:19 PM in response to Achilleus
    I don't see that happening, either. Run this in Terminal and post the results:

    diff -wBy --suppress-common-lines /etc/apache2/httpd.conf /etc/apache2/original/httpd.conf 
  • by Achilleus,

    Achilleus Achilleus Jul 29, 2008 3:34 PM in response to orangekay
    Level 1 (0 points)
    Jul 29, 2008 3:34 PM in response to orangekay
    orangekay wrote:
    I don't see that happening, either. Run this in Terminal and post the results:

    diff -wBy --suppress-common-lines /etc/apache2/httpd.conf /etc/apache2/original/httpd.conf

    sh-3.2# diff -wBy --suppress-common-lines /etc/apache2/httpd.conf /etc/apache2/original/httpd.conf
    # with "/", the value of ServerRoot is prepended -- so "/priv | # with "/", the value of ServerRoot is prepended -- so "/priv
    # server as "/usr//private/var/log/apache2/foo.log". | # server as "/usr//private/var/log/apache2/foo_log".
    > LoadModule substitute_module libexec/apache2/mod_substitute.s
    #LoadModule uniqueidmodule libexec/apache2/moduniqueid.so | LoadModule uniqueidmodule libexec/apache2/moduniqueid.so
    LoadModule bonjour_module libexec/apache2/mod_bonjour.so <
    LoadModule php5_module libexec/apache2/libphp5.so <
    #LoadModule fastcgi_module libexec/apache2/mod_fastcgi.so <IfModule !mpmwinntmodule>
    >
    > </IfModule>
    ServerAdmin admin@localhost | ServerAdmin you@example.com
    AllowOverride All | AllowOverride None
    Allow from all | Deny from all
    RewriteLog /var/log/apache2/rewrite.log <
    RewriteLogLevel 9 <
    <
    Options All Indexes FollowSymLinks MultiViews | Options Indexes FollowSymLinks MultiViews
    RewriteEngine On |
    AllowOverride All | AllowOverride None
    ErrorLog /private/var/log/apache2/error_log | ErrorLog "/private/var/log/apache2/error_log"
    CustomLog /private/var/log/apache2/access_log common | CustomLog "/private/var/log/apache2/access_log" common
    #CustomLog /private/var/log/apache2/access_log combined | #CustomLog "/private/var/log/apache2/access_log" combined


    There's the results. It is adding a trailing slash at the end of games.html, that's what the 404 page is telling me that it can't find.

    Message was edited by: Achilleus

    Message was edited by: Achilleus
  • by orangekay,

    orangekay orangekay Jul 29, 2008 3:49 PM in response to Achilleus
    Level 5 (4,085 points)
    Jul 29, 2008 3:49 PM in response to Achilleus
    OK, so keep it simple:

    RewriteEngine on
    RewriteRule ^foo(/)?$ index.html [L]


    Then load http://localhost/foo while watching your rewrite log with tail -f and see what happens.
  • by Achilleus,

    Achilleus Achilleus Jul 29, 2008 3:54 PM in response to orangekay
    Level 1 (0 points)
    Jul 29, 2008 3:54 PM in response to orangekay
    No trailing slash, that seems to have worked. A guy in another forum just told me that it's that [L] flag, I'm gonna uncomment the php lines and add [L] and see if it all works now.

    Thanks for the help
  • by Achilleus,

    Achilleus Achilleus Jul 29, 2008 4:07 PM in response to Achilleus
    Level 1 (0 points)
    Jul 29, 2008 4:07 PM in response to Achilleus
    Now this is strange...it's trying to find games.html/ again even after uncommenting that line in .htaccess and dumping my cache in Safari. I even restarted apache.

    RewriteEngine on
    #RewriteRule ^games(/)?$ games.html [L]
    RewriteRule ^games(/)?$ index.php?action=games [L]
    #RewriteRule ^events(/)?$ index.php?action=events [L]
    #RewriteRule ^downloads(/)?$ index.php?action=downloads [L]
    #RewriteRule ^support(/)?$ index.php?action=support [L]
    #RewriteRule ^blogs(/)?$ wordpress/ [L]


     Tuesday, July 29, 2008 5:59:44 PM US/Central 
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#10096c898/subreq] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.html -> /Library/WebServer/Documents/games.html/
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#10096c898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.html/ -> games.html/
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#10096c898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri 'games.html/'
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#10096c898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.html
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#100978898/subreq] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.php -> /Library/WebServer/Documents/games.php/
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#100978898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.php/ -> games.php/
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#100978898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri 'games.php/'
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#100978898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.php
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.template.php -> /Library/WebServer/Documents/games.template.php/
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.template.php/ -> games.template.php/
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri 'games.template.php/'
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.template.php
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#10097e898/initial] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.html -> /Library/WebServer/Documents/games.html/
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#10097e898/initial] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.html/ -> games.html/
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#10097e898/initial] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri 'games.html/'
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#10097e898/initial] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.html
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#100983498/initial] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/favicon.ico -> favicon.ico
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#100983498/initial] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri 'favicon.ico'
    ::1 - - [29/Jul/2008:17:59:47 --0500] [localhost/sid#10080b708][rid#100983498/initial] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/favicon.ico


    That's my info that comes up on the rewrite_log and it still doesn't look right. Works if I have the top line uncommented and goes to games.html, but if I use the second line which is what I actually need working, it's all completely screwed up.

    After removing games.html from the documents folder, this is the new log I get:

     Tuesday, July 29, 2008 6:04:51 PM US/Central 
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100983498/subreq] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.php -> /Library/WebServer/Documents/games.php/
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100983498/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.php/ -> games.php/
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100983498/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri 'games.php/'
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100983498/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.php
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100975898/subreq] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.template.php -> /Library/WebServer/Documents/games.template.php/
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100975898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.template.php/ -> games.template.php/
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100975898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri 'games.template.php/'
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100975898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.template.php
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10096e898/initial] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.php -> /Library/WebServer/Documents/games.php/
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10096e898/initial] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.php/ -> games.php/
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10096e898/initial] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri 'games.php/'
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10096e898/initial] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.php
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100970898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/ ->
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100970898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri ''
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100970898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/index.html -> index.html
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri 'index.html'
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/index.html
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100985498/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/index.html -> index.html
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100985498/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri 'index.html'
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#100985498/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/index.html
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/index.php -> index.php
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri 'index.php'
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/index.php
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10096c898/initial] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/favicon.ico -> favicon.ico
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10096c898/initial] (3) [perdir /Library/WebServer/Documents> applying pattern '^games(/)?$' to uri 'favicon.ico'
    ::1 - - [29/Jul/2008:18:04:54 --0500] [localhost/sid#10080b708][rid#10096c898/initial] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/favicon.ico


    Very strange, considering that I don't even have an index.html file in the folder.
  • by Camelot,

    Camelot Camelot Jul 29, 2008 4:11 PM in response to glsmith
    Level 8 (47,305 points)
    Mac OS X
    Jul 29, 2008 4:11 PM in response to glsmith
    -- moved --

    Message was edited by: Camelot
  • by Camelot,

    Camelot Camelot Jul 29, 2008 4:12 PM in response to Achilleus
    Level 8 (47,305 points)
    Mac OS X
    Jul 29, 2008 4:12 PM in response to Achilleus
    Gosh, it's obvious when you look, isn't it.

    It's not a problem with .htaccess at all. Your RewriteRules are the issue.

    RewriteRule ^games/$ index\.php\?action\=games


    This says "rewrite any URI that matches "games/"

    This will never work. Ever.

    Every URI begins with a leading /
    Therefore the correct Rule would be:

    RewriteRule ^/games/$ index\.php\?action\=games


    In other words, match '/games/', not 'games/'

    That leading slash is critical.

    (and sorry about the RewriteLogs - I did say they'd get verbose
  • by orangekay,

    orangekay orangekay Jul 29, 2008 4:13 PM in response to Achilleus
    Level 5 (4,085 points)
    Jul 29, 2008 4:13 PM in response to Achilleus
    Now get rid of the backslashes in your replacement patterns.
  • by Achilleus,

    Achilleus Achilleus Jul 29, 2008 4:16 PM in response to Camelot
    Level 1 (0 points)
    Jul 29, 2008 4:16 PM in response to Camelot
     Tuesday, July 29, 2008 6:13:33 PM US/Central 
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#100978898/subreq] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.php -> /Library/WebServer/Documents/games.php/
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#100978898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.php/ -> games.php/
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#100978898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'games.php/'
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#100978898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.php
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.template.php -> /Library/WebServer/Documents/games.template.php/
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.template.php/ -> games.template.php/
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'games.template.php/'
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097a898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.template.php
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10096c898/initial] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.php -> /Library/WebServer/Documents/games.php/
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10096c898/initial] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.php/ -> games.php/
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10096c898/initial] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'games.php/'
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10096c898/initial] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.php
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097c898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/ ->
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097c898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri ''
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097c898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097e898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/index.html -> index.html
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097e898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'index.html'
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097e898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/index.html
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#100982898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/index.html -> index.html
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#100982898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'index.html'
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#100982898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/index.html
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097e898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/index.php -> index.php
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097e898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'index.php'
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#10097e898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/index.php
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#100975898/initial] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/favicon.ico -> favicon.ico
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#100975898/initial] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'favicon.ico'
    ::1 - - [29/Jul/2008:18:13:38 --0500] [localhost/sid#10080b708][rid#100975898/initial] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/favicon.ico


    That's the log I get when I make your suggested change. Not even a 404 this time, just a blank white page. It worked just fine without the leading slash on my windows apache. The problem is the TRAILING slash that it's adding to my php files, and I have no clue why it's looking for an index.html because it's not even being requested.
  • by Achilleus,

    Achilleus Achilleus Jul 29, 2008 4:20 PM in response to orangekay
    Level 1 (0 points)
    Jul 29, 2008 4:20 PM in response to orangekay
    The backslashes are there to escape the ? the = and the . so that way they will(theoretically) show up in the URL. Well not "show up" since I want all that hidden but the URL it has to go to is index.php?action=games
  • by orangekay,

    orangekay orangekay Jul 29, 2008 4:32 PM in response to Achilleus
    Level 5 (4,085 points)
    Jul 29, 2008 4:32 PM in response to Achilleus
    The rewrite targets are not regular expressions and do not require escaping. The only processing that should be done on these is the expansion of backreferences to the preceding regex.
  • by Achilleus,

    Achilleus Achilleus Jul 29, 2008 4:36 PM in response to orangekay
    Level 1 (0 points)
    Jul 29, 2008 4:36 PM in response to orangekay
    Either way, with or without the backslashes, it still won't work.

     Tuesday, July 29, 2008 6:35:16 PM US/Central 
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100978898/subreq] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.php -> /Library/WebServer/Documents/games.php/
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100978898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.php/ -> games.php/
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100978898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'games.php/'
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100978898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.php
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10096e898/subreq] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.template.php -> /Library/WebServer/Documents/games.template.php/
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10096e898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.template.php/ -> games.template.php/
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10096e898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'games.template.php/'
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10096e898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.template.php
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100970898/initial] (3) [perdir /Library/WebServer/Documents> add path info postfix: /Library/WebServer/Documents/games.php -> /Library/WebServer/Documents/games.php/
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100970898/initial] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/games.php/ -> games.php/
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100970898/initial] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'games.php/'
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100970898/initial] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/games.php
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10096c898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/ ->
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10096c898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri ''
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10096c898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10097e898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/index.html -> index.html
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10097e898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'index.html'
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10097e898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/index.html
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100982898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/index.html -> index.html
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100982898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'index.html'
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100982898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/index.html
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10097e898/subreq] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/index.php -> index.php
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10097e898/subreq] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'index.php'
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#10097e898/subreq] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/index.php
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100975898/initial] (3) [perdir /Library/WebServer/Documents> strip per-dir prefix: /Library/WebServer/Documents/favicon.ico -> favicon.ico
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100975898/initial] (3) [perdir /Library/WebServer/Documents> applying pattern '^/games(/)?$' to uri 'favicon.ico'
    ::1 - - [29/Jul/2008:18:35:20 --0500] [localhost/sid#10080b708][rid#100975898/initial] (1) [perdir /Library/WebServer/Documents> pass through /Library/WebServer/Documents/favicon.ico


    Without backslashes.

    RewriteEngine on
    #RewriteRule ^games(/)?$ games.html [L]
    RewriteRule ^/games(/)?$ index.php?action=games [L]
    #RewriteRule ^events(/)?$ index.php?action=events [L]
    #RewriteRule ^downloads(/)?$ index.php?action=downloads [L]
    #RewriteRule ^support(/)?$ index.php?action=support [L]
    #RewriteRule ^blogs(/)?$ wordpress/ [L]
  • by orangekay,

    orangekay orangekay Jul 29, 2008 4:44 PM in response to Camelot
    Level 5 (4,085 points)
    Jul 29, 2008 4:44 PM in response to Camelot
    Camelot wrote:
    Every URI begins with a leading /


    That's not necessarily true if you're defining rules in a per-directory context.
Previous Page 2 of 3 last Next