Apache Server configuration support - [mod_rewrite] www.server.com/XX --> www.server.com/item.php?id=XX

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > January 2007 > [mod_rewrite] www.server.com/XX --> www.server.com/item.php?id=XX





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author [mod_rewrite] www.server.com/XX --> www.server.com/item.php?id=XX

2007-01-06, 8:12 pm

Hello:

RewriteEngine On
RewriteRule ^([a-z0-9_-]+)?$ where.php [L]

This is my simple .htaccess. It sends to where.php, which then takes visitor
to the proper place. The reason is that I have index.php file and ok/
directory in the main folder, so addresses www.server.com/index.php
www.server.com/ and www.serwer.com/ok should not be changed but everything
else that starts from www.server.com should go to
www.server.com/item.php?id= and the where.php is the script that shooses
where to send the user.
How can I do it without where.php script?

Regards,
Talthen


Rik

2007-01-06, 8:12 pm

talthen.z-serwera.o2@nospam.pl wrote:
> Hello:
>
> RewriteEngine On
> RewriteRule ^([a-z0-9_-]+)?$ where.php [L]
>
> This is my simple .htaccess. It sends to where.php, which then takes
> visitor to the proper place. The reason is that I have index.php file
> and ok/ directory in the main folder, so addresses
> www.server.com/index.php www.server.com/ and www.serwer.com/ok should
> not be changed but everything else that starts from www.server.com
> should go to www.server.com/item.php?id= and the where.php is the
> script that shooses where to send the user.
> How can I do it without where.php script?


I usually solve this by inspecting wether a file exists:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?id=$1 {L,QSA]
--
Rik Wasmus


2007-01-07, 7:25 am

"Rik" <luiheidsgoeroe@hotmail.com> wrote:
> I usually solve this by inspecting wether a file exists:
>
> RewriteEngine On
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteRule ^(.+)$ index.php?id=$1 {L,QSA]


I changed
RewriteRule ^(.+)$ index.php?id=$1 {L,QSA]
to
RewriteRule ^(.+)$ index.php?id=$1 [L,QSA]
and works great. Thank you!

Regards,
Talthen


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com