Mod_Rewrite is not working correctly

adamshields
adamshields used Ask the Experts™
on
I have a Pastebin install that is not working correctly.

You can download a copy from: http://pastebin.com/pastebin.tar.gz

The rewrite rule doesn't seem to be working. I know mod_rewrite is turned on.

I get the following error:

[Fri Jan 29 09:09:19 2010] [error] [client 198.186.38.31] File does not exist: /var/www/pastebin/22, referer: http://127.0.0.1/pastebin/pastebin.php?show=16
###Entry within default Apache virtual host
        DocumentRoot /var/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        <Directory "/var/www/pastebin/">
                php_value include_path .:/var/www/pastebin/lib
                php_value register_globals off
                DirectoryIndex pastebin.php
                RewriteEngine on
                RewriteRule /([a-z0-9]+) /pastebin.php?show=$1
                #RewriteRule /([0-9]+) /pastebin.php?show=$1
                #RewriteRule /pastebin(.*) /pastebin$1
                #RewriteRule /pastebin(.*) /pastebin$1 [PT]
        </Directory>

Open in new window

config.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010

Commented:
Hi

Apologies no access to Apache today, so can't play. Anyway try temporarily replacing the existing logic with:

RewriteEngine on
RewriteLog        /tmp/ReWriteLog.log
RewriteLogLevel 9
RewriteRule ^/pastebin/([a-z0-9]*)  ^/pastebin/pastebin.php?show=$1 [L]
#RewriteRule /([a-z0-9]+) /pastebin.php?show=$1
...

If it dosen't solve the issue, have a look at the log, will show you what was passed, and what it's trying to match it to.

Author

Commented:
There are two examples in the following error logs. The first is the original rewrite rule. The second is what you recommend.
#### Original rule for opening the initial index page.

************* - - [29/Jan/2010:09:24:14 --0500] [********/sid#8b2d300][rid#8cda238/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/ ->
************* - - [29/Jan/2010:09:24:14 --0500] [********/sid#8b2d300][rid#8cda238/initial] (3) [perdir /var/www/pastebin/] applying pattern '/([a-z0-9]+)' to uri ''
************* - - [29/Jan/2010:09:24:14 --0500] [********/sid#8b2d300][rid#8cda238/initial] (1) [perdir /var/www/pastebin/] pass through /var/www/pastebin/
************* - - [29/Jan/2010:09:24:14 --0500] [********/sid#8b2d300][rid#8cd0168/subreq] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.php -> pastebin.php
************* - - [29/Jan/2010:09:24:14 --0500] [********/sid#8b2d300][rid#8cd0168/subreq] (3) [perdir /var/www/pastebin/] applying pattern '/([a-z0-9]+)' to uri 'pastebin.php'
************* - - [29/Jan/2010:09:24:14 --0500] [********/sid#8b2d300][rid#8cd0168/subreq] (1) [perdir /var/www/pastebin/] pass through /var/www/pastebin/pastebin.php
************* - - [29/Jan/2010:09:24:15 --0500] [********/sid#8b2d300][rid#8cd8230/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.css -> pastebin.css
************* - - [29/Jan/2010:09:24:15 --0500] [********/sid#8b2d300][rid#8cd8230/initial] (3) [perdir /var/www/pastebin/] applying pattern '/([a-z0-9]+)' to uri 'pastebin.css'
************* - - [29/Jan/2010:09:24:15 --0500] [********/sid#8b2d300][rid#8cd8230/initial] (1) [perdir /var/www/pastebin/] pass through /var/www/pastebin/pastebin.css
************* - - [29/Jan/2010:09:24:15 --0500] [********/sid#8b2d300][rid#8cd0168/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.js -> pastebin.js
************* - - [29/Jan/2010:09:24:15 --0500] [********/sid#8b2d300][rid#8cd0168/initial] (3) [perdir /var/www/pastebin/] applying pattern '/([a-z0-9]+)' to uri 'pastebin.js'
************* - - [29/Jan/2010:09:24:15 --0500] [********/sid#8b2d300][rid#8cd0168/initial] (1) [perdir /var/www/pastebin/] pass through /var/www/pastebin/pastebin.js

#### Rewrite statement that isn't working with original regex.

************* - - [29/Jan/2010:09:25:11 --0500] [********/sid#8b2d300][rid#8cd0168/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/20 -> 20
************* - - [29/Jan/2010:09:25:11 --0500] [********/sid#8b2d300][rid#8cd0168/initial] (3) [perdir /var/www/pastebin/] applying pattern '/([a-z0-9]+)' to uri '20'
************* - - [29/Jan/2010:09:25:11 --0500] [********/sid#8b2d300][rid#8cd0168/initial] (1) [perdir /var/www/pastebin/] pass through /var/www/pastebin/20


#### Your recommended rule for opening the initial index page.

************* - - [29/Jan/2010:09:28:03 --0500] [********/sid#8ef0300][rid#909d248/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/ ->
************* - - [29/Jan/2010:09:28:03 --0500] [********/sid#8ef0300][rid#909d248/initial] (3) [perdir /var/www/pastebin/] applying pattern '^/pastebin/([a-z0-9]*)' to uri ''
************* - - [29/Jan/2010:09:28:03 --0500] [********/sid#8ef0300][rid#909d248/initial] (1) [perdir /var/www/pastebin/] pass through /var/www/pastebin/
************* - - [29/Jan/2010:09:28:03 --0500] [********/sid#8ef0300][rid#9093178/subreq] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.php -> pastebin.php
************* - - [29/Jan/2010:09:28:03 --0500] [********/sid#8ef0300][rid#9093178/subreq] (3) [perdir /var/www/pastebin/] applying pattern '^/pastebin/([a-z0-9]*)' to uri 'pastebin.php'
************* - - [29/Jan/2010:09:28:03 --0500] [********/sid#8ef0300][rid#9093178/subreq] (1) [perdir /var/www/pastebin/] pass through /var/www/pastebin/pastebin.php
************* - - [29/Jan/2010:09:28:03 --0500] [********/sid#8ef0300][rid#909b240/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.css -> pastebin.css
************* - - [29/Jan/2010:09:28:03 --0500] [********/sid#8ef0300][rid#909b240/initial] (3) [perdir /var/www/pastebin/] applying pattern '^/pastebin/([a-z0-9]*)' to uri 'pastebin.css'
************* - - [29/Jan/2010:09:28:03 --0500] [********/sid#8ef0300][rid#909b240/initial] (1) [perdir /var/www/pastebin/] pass through /var/www/pastebin/pastebin.css
************* - - [29/Jan/2010:09:28:03 --0500] [********/sid#8ef0300][rid#9093178/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.js -> pastebin.js
************* - - [29/Jan/2010:09:28:03 --0500] [********/sid#8ef0300][rid#9093178/initial] (3) [perdir /var/www/pastebin/] applying pattern '^/pastebin/([a-z0-9]*)' to uri 'pastebin.js'
************* - - [29/Jan/2010:09:28:03 --0500] [********/sid#8ef0300][rid#9093178/initial] (1) [perdir /var/www/pastebin/] pass through /var/www/pastebin/pastebin.js

#### Rewrite statement that isn't working with your regex.

************* - - [29/Jan/2010:09:28:46 --0500] [********/sid#8ef0300][rid#9093178/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/16 -> 16
************* - - [29/Jan/2010:09:28:46 --0500] [********/sid#8ef0300][rid#9093178/initial] (3) [perdir /var/www/pastebin/] applying pattern '^/pastebin/([a-z0-9]*)' to uri '16'
************* - - [29/Jan/2010:09:28:46 --0500] [********/sid#8ef0300][rid#9093178/initial] (1) [perdir /var/www/pastebin/] pass through /var/www/pastebin/16

Open in new window

Author

Commented:
Also there is a configuration variable for the application which I'm including below. Per the author. If I enable the second variable then it work using the whole URL but of course I'm looking to use the shortened version.
/**
 * format of urls to pastebin entries - %d is the placeholder for
 * the entry id.
 *
 * 1. for shortest possible url generation in conjuction with mod_rewrite:
 *    $CONF['url_format']='/%s';
 *
 * 2. if using pastebin with mod_rewrite, but within a subdir, you'd use
 *    something like this:
 *    $CONF['url_format']="/mysubdir/%s";
 *
 * 3. if not using mod_rewrite, you'll need something more like this:
 *    $CONF['url_format']="/pastebin.php?show=%s";
 */
$CONF['url_format']='/pastebin/%s';
#$CONF['url_format']="/pastebin/pastebin.php?show=%s";

Open in new window

11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

Author

Commented:
Update, see below.



# I can get the following to work: 
RewriteRule ([0-9]+) pastebin.php?show=$1

# The following do not. I wonder if its because the string doesn't match? This install is only using numbers at this point but I imagine at some point it begins to also include letters. Is there a way to make the pattern use both but not require numbers and letters?

RewriteRule ([a-z0-9]*) pastebin.php?show=$1
RewriteRule ([a-z0-9]+) pastebin.php?show=$1

Open in new window

Top Expert 2010

Commented:
What do you get in the logs when you have both the following rules present?

RewriteRule ([a-z0-9]*) pastebin.php?show=$1
RewriteRule ([a-z0-9]+) pastebin.php?show=$1

Author

Commented:
Log is post below with the two rewrite rules enabled. When using the [a-z09] does that mean that the alpha or numeric is optional or are both required? I'm assuming the * allows for a-z AND/OR 0-9? If both are required that would definitely be an issue as currently numeric entries are defined for $1
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/31 -> 31
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) [perdir /var/www/pastebin/] applying pattern '([a-z0-9]*)' to uri '31'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (2) [perdir /var/www/pastebin/] rewrite '31' -> 'pastebin.php?show=31'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) split uri=pastebin.php?show=31 -> uri=pastebin.php, args=show=31
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) [perdir /var/www/pastebin/] add per-dir prefix: pastebin.php -> /var/www/pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.php -> pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) [perdir /var/www/pastebin/] applying pattern '([a-z0-9]+)' to uri 'pastebin.php'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (2) [perdir /var/www/pastebin/] rewrite 'pastebin.php' -> 'pastebin.php?show=pastebin'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) split uri=pastebin.php?show=pastebin -> uri=pastebin.php, args=show=pastebin
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) [perdir /var/www/pastebin/] add per-dir prefix: pastebin.php -> /var/www/pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (2) [perdir /var/www/pastebin/] strip document_root prefix: /var/www/pastebin/pastebin.php -> /pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (1) [perdir /var/www/pastebin/] internal redirect with /pastebin/pastebin.php [INTERNAL REDIRECT]
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b928/initial/redir#1] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.php -> pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b928/initial/redir#1] (3) [perdir /var/www/pastebin/] applying pattern '([a-z0-9]*)' to uri 'pastebin.php'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b928/initial/redir#1] (2) [perdir /var/www/pastebin/] rewrite 'pastebin.php' -> 'pastebin.php?show=pastebin'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b928/initial/redir#1] (3) split uri=pastebin.php?show=pastebin -> uri=pastebin.php, args=show=pastebin
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b928/initial/redir#1] (3) [perdir /var/www/pastebin/] add per-dir prefix: pastebin.php -> /var/www/pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b928/initial/redir#1] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.php -> pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b928/initial/redir#1] (3) [perdir /var/www/pastebin/] applying pattern '([a-z0-9]+)' to uri 'pastebin.php'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b928/initial/redir#1] (2) [perdir /var/www/pastebin/] rewrite 'pastebin.php' -> 'pastebin.php?show=pastebin'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b928/initial/redir#1] (3) split uri=pastebin.php?show=pastebin -> uri=pastebin.php, args=show=pastebin
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b928/initial/redir#1] (3) [perdir /var/www/pastebin/] add per-dir prefix: pastebin.php -> /var/www/pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b928/initial/redir#1] (1) [perdir /var/www/pastebin/] initial URL equal rewritten URL: /var/www/pastebin/pastebin.php [IGNORING REWRITE]
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b288/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.css -> pastebin.css
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b288/initial] (3) [perdir /var/www/pastebin/] applying pattern '([a-z0-9]*)' to uri 'pastebin.css'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b288/initial] (2) [perdir /var/www/pastebin/] rewrite 'pastebin.css' -> 'pastebin.php?show=pastebin'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b288/initial] (3) split uri=pastebin.php?show=pastebin -> uri=pastebin.php, args=show=pastebin
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b288/initial] (3) [perdir /var/www/pastebin/] add per-dir prefix: pastebin.php -> /var/www/pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b288/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.php -> pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b288/initial] (3) [perdir /var/www/pastebin/] applying pattern '([a-z0-9]+)' to uri 'pastebin.php'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b288/initial] (2) [perdir /var/www/pastebin/] rewrite 'pastebin.php' -> 'pastebin.php?show=pastebin'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b288/initial] (3) split uri=pastebin.php?show=pastebin -> uri=pastebin.php, args=show=pastebin
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b288/initial] (3) [perdir /var/www/pastebin/] add per-dir prefix: pastebin.php -> /var/www/pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b288/initial] (2) [perdir /var/www/pastebin/] strip document_root prefix: /var/www/pastebin/pastebin.php -> /pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988b288/initial] (1) [perdir /var/www/pastebin/] internal redirect with /pastebin/pastebin.php [INTERNAL REDIRECT]
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988df48/initial/redir#1] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.php -> pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988df48/initial/redir#1] (3) [perdir /var/www/pastebin/] applying pattern '([a-z0-9]*)' to uri 'pastebin.php'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988df48/initial/redir#1] (2) [perdir /var/www/pastebin/] rewrite 'pastebin.php' -> 'pastebin.php?show=pastebin'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988df48/initial/redir#1] (3) split uri=pastebin.php?show=pastebin -> uri=pastebin.php, args=show=pastebin
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988df48/initial/redir#1] (3) [perdir /var/www/pastebin/] add per-dir prefix: pastebin.php -> /var/www/pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988df48/initial/redir#1] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.php -> pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988df48/initial/redir#1] (3) [perdir /var/www/pastebin/] applying pattern '([a-z0-9]+)' to uri 'pastebin.php'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988df48/initial/redir#1] (2) [perdir /var/www/pastebin/] rewrite 'pastebin.php' -> 'pastebin.php?show=pastebin'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988df48/initial/redir#1] (3) split uri=pastebin.php?show=pastebin -> uri=pastebin.php, args=show=pastebin
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988df48/initial/redir#1] (3) [perdir /var/www/pastebin/] add per-dir prefix: pastebin.php -> /var/www/pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#988df48/initial/redir#1] (1) [perdir /var/www/pastebin/] initial URL equal rewritten URL: /var/www/pastebin/pastebin.php [IGNORING REWRITE]
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.js -> pastebin.js
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) [perdir /var/www/pastebin/] applying pattern '([a-z0-9]*)' to uri 'pastebin.js'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (2) [perdir /var/www/pastebin/] rewrite 'pastebin.js' -> 'pastebin.php?show=pastebin'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) split uri=pastebin.php?show=pastebin -> uri=pastebin.php, args=show=pastebin
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) [perdir /var/www/pastebin/] add per-dir prefix: pastebin.php -> /var/www/pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.php -> pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) [perdir /var/www/pastebin/] applying pattern '([a-z0-9]+)' to uri 'pastebin.php'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (2) [perdir /var/www/pastebin/] rewrite 'pastebin.php' -> 'pastebin.php?show=pastebin'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) split uri=pastebin.php?show=pastebin -> uri=pastebin.php, args=show=pastebin
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (3) [perdir /var/www/pastebin/] add per-dir prefix: pastebin.php -> /var/www/pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (2) [perdir /var/www/pastebin/] strip document_root prefix: /var/www/pastebin/pastebin.php -> /pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#98851c8/initial] (1) [perdir /var/www/pastebin/] internal redirect with /pastebin/pastebin.php [INTERNAL REDIRECT]
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#9889f38/initial/redir#1] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.php -> pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#9889f38/initial/redir#1] (3) [perdir /var/www/pastebin/] applying pattern '([a-z0-9]*)' to uri 'pastebin.php'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#9889f38/initial/redir#1] (2) [perdir /var/www/pastebin/] rewrite 'pastebin.php' -> 'pastebin.php?show=pastebin'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#9889f38/initial/redir#1] (3) split uri=pastebin.php?show=pastebin -> uri=pastebin.php, args=show=pastebin
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#9889f38/initial/redir#1] (3) [perdir /var/www/pastebin/] add per-dir prefix: pastebin.php -> /var/www/pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#9889f38/initial/redir#1] (3) [perdir /var/www/pastebin/] strip per-dir prefix: /var/www/pastebin/pastebin.php -> pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#9889f38/initial/redir#1] (3) [perdir /var/www/pastebin/] applying pattern '([a-z0-9]+)' to uri 'pastebin.php'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#9889f38/initial/redir#1] (2) [perdir /var/www/pastebin/] rewrite 'pastebin.php' -> 'pastebin.php?show=pastebin'
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#9889f38/initial/redir#1] (3) split uri=pastebin.php?show=pastebin -> uri=pastebin.php, args=show=pastebin
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#9889f38/initial/redir#1] (3) [perdir /var/www/pastebin/] add per-dir prefix: pastebin.php -> /var/www/pastebin/pastebin.php
************* - - [30/Jan/2010:06:31:55 --0500] [************/sid#96e2300][rid#9889f38/initial/redir#1] (1) [perdir /var/www/pastebin/] initial URL equal rewritten URL: /var/www/pastebin/pastebin.php [IGNORING REWRITE]

Open in new window

Top Expert 2010

Commented:
Hi

Becomes clear, you need to exclude the /pastebin/pastebin.php from the rule, or probaably any .php script in that directory e.g.

RewriteCond %{REQUEST_URI}  ! .php
RewriteRule ([a-z0-9]*) pastebin.php?show=$1
Top Expert 2010
Commented:
Attempt 2:

Becomes clear, you need to exclude the /pastebin/pastebin.php from the rule, or probaably any .php, .js, .css, .jpg files in that directory e.g.

Could do it this way:

RewriteCond %{REQUEST_URI}  ! \.[php|js|css|jpg|gif]
RewriteRule ([a-z0-9]*) pastebin.php?show=$1

Alternatively change the rule to just accpe whole words:

RewriteRule ^([a-z0-9]*)$ pastebin.php?show=$1

Author

Commented:
The second one accepting whole words worked!!!

Thanks

Author

Commented:
The second one works. Did bother trying to first so it may also work.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial