Mod rewrite and parameters

This is a discussion on Mod rewrite and parameters within the Linux Web Servers forums, part of the Web Server and Related Forums category; I have the following .htaccess RewriteEngine On RewriteBase /~hkosmidi/web/ima/admin/ RewriteRule ^.*(\.css)|(\.jpg)|(\.png)|(\.html)|(\.gif)|(\.js) |(\.txt)|(\....


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-28-2008
Harris Kosmidis
 
Posts: n/a
Default Mod rewrite and parameters

I have the following .htaccess

RewriteEngine On
RewriteBase /~hkosmidi/web/ima/admin/
RewriteRule
^.*(\.css)|(\.jpg)|(\.png)|(\.html)|(\.gif)|(\.js) |(\.txt)|(\.ico)$ - [L]

RewriteRule ^index.php$ index.php [L]
RewriteRule ^companies?err=([0-9])$ index.php?module=companies&err=$1 [L]
RewriteRule ^companies$ index.php?module=companies [L]
RewriteRule ^categories?err=([0-9])$ index.php?module=categories&err=$1 [L]
RewriteRule ^categories$ index.php?module=categories [L]
RewriteRule ^compcategory?err=([0-9])$
index.php?module=compcategory&err=$1 [L]
RewriteRule ^compcategory$ index.php?module=compcategory [L]
RewriteRule ^products?err=([0-9])$ index.php?module=products&err=$1 [L]
RewriteRule ^products$ index.php?module=products [L]

Now if I say:
http://localhost/~hkosmidi/web/ima/admin/categories

the appropriate module is loaded.

But if I say:
http://localhost/~hkosmidi/web/ima/a...tegories?err=1

then I can't $_GET the param from php. The rewrite log has:
127.0.0.1 - - [28/Jan/2008:20:38:54 +0200]
[localhost/sid#81da180][rid#838bfe0/initial] (3) [perdir
/home/hkosmidi/public_html/web/ima/admin/] applying pattern
'^categories?err=([0-9])$' to uri 'categories'
127.0.0.1 - - [28/Jan/2008:20:38:54 +0200]
[localhost/sid#81da180][rid#838bfe0/initial] (3) [perdir
/home/hkosmidi/public_html/web/ima/admin/] strip per-dir prefix:
/home/hkosmidi/public_html/web/ima/admin/categories -> categories
127.0.0.1 - - [28/Jan/2008:20:38:54 +0200]
[localhost/sid#81da180][rid#838bfe0/initial] (3) [perdir
/home/hkosmidi/public_html/web/ima/admin/] applying pattern
'^categories$' to uri 'categories'
127.0.0.1 - - [28/Jan/2008:20:38:54 +0200]
[localhost/sid#81da180][rid#838bfe0/initial] (2) [perdir
/home/hkosmidi/public_html/web/ima/admin/] rewrite 'categories' ->
'index.php?module=categories'
127.0.0.1 - - [28/Jan/2008:20:38:54 +0200]
[localhost/sid#81da180][rid#838bfe0/initial] (3) split
uri=index.php?module=categories -> uri=index.php, args=module=categories


How can I pass GET params with mod_rewrite?


thanks
  #2 (permalink)  
Old 01-28-2008
Jim Hayter
 
Posts: n/a
Default Re: Mod rewrite and parameters

Harris Kosmidis wrote:
> I have the following .htaccess
>
> RewriteEngine On
> RewriteBase /~hkosmidi/web/ima/admin/
> RewriteRule
> ^.*(\.css)|(\.jpg)|(\.png)|(\.html)|(\.gif)|(\.js) |(\.txt)|(\.ico)$ - [L]
>
> RewriteRule ^index.php$ index.php [L]
> RewriteRule ^companies?err=([0-9])$ index.php?module=companies&err=$1 [L]
> RewriteRule ^companies$ index.php?module=companies [L]
> RewriteRule ^categories?err=([0-9])$ index.php?module=categories&err=$1 [L]
> RewriteRule ^categories$ index.php?module=categories [L]
> RewriteRule ^compcategory?err=([0-9])$
> index.php?module=compcategory&err=$1 [L]
> RewriteRule ^compcategory$ index.php?module=compcategory [L]
> RewriteRule ^products?err=([0-9])$ index.php?module=products&err=$1 [L]
> RewriteRule ^products$ index.php?module=products [L]
>
> Now if I say:
> http://localhost/~hkosmidi/web/ima/admin/categories
>
> the appropriate module is loaded.
>
> But if I say:
> http://localhost/~hkosmidi/web/ima/a...tegories?err=1
>
> then I can't $_GET the param from php. The rewrite log has:
> 127.0.0.1 - - [28/Jan/2008:20:38:54 +0200]
> [localhost/sid#81da180][rid#838bfe0/initial] (3) [perdir
> /home/hkosmidi/public_html/web/ima/admin/] applying pattern
> '^categories?err=([0-9])$' to uri 'categories'
> 127.0.0.1 - - [28/Jan/2008:20:38:54 +0200]
> [localhost/sid#81da180][rid#838bfe0/initial] (3) [perdir
> /home/hkosmidi/public_html/web/ima/admin/] strip per-dir prefix:
> /home/hkosmidi/public_html/web/ima/admin/categories -> categories
> 127.0.0.1 - - [28/Jan/2008:20:38:54 +0200]
> [localhost/sid#81da180][rid#838bfe0/initial] (3) [perdir
> /home/hkosmidi/public_html/web/ima/admin/] applying pattern
> '^categories$' to uri 'categories'
> 127.0.0.1 - - [28/Jan/2008:20:38:54 +0200]
> [localhost/sid#81da180][rid#838bfe0/initial] (2) [perdir
> /home/hkosmidi/public_html/web/ima/admin/] rewrite 'categories' ->
> 'index.php?module=categories'
> 127.0.0.1 - - [28/Jan/2008:20:38:54 +0200]
> [localhost/sid#81da180][rid#838bfe0/initial] (3) split
> uri=index.php?module=categories -> uri=index.php, args=module=categories
>
>
> How can I pass GET params with mod_rewrite?
>
>
> thanks



The query string is not part of the object examined by a RewriteRule.
Read up on RewriteCond and find examples that look at %{QUERY_STRING}.
You should find examples in the history of this newsgroup via google.

Jim
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:07 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0