Joe Terranova on 14 May 2008 13:37:42 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] regex question


On Tue, May 13, 2008 at 7:11 PM, John Sladek <jsladek@comcast.net> wrote:
> I'm trying to detect a url like this
> http://www.mysite.com/anything
> but not this
> http://www.mysite.com/anything.php
> I'll then be rewriting from
> http://www.mysite.com/anything
> to
> http://www.mysite.com/public.php?page=anything

You probably want to do something like this. This is what I do for my
wordpress, and I just changed theRewriteRule line for your purposes.
Basically, it checks to see if the url exists as a file or a
directory; if not, it takes everything after the / and puts it in the
format you wanted.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ /public.php?page=$1 [L]
</IfModule>

Let me know if you need anything else with this.

Cheers,
Joe Terranova
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug