You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Kunal <ku...@empirehost.com> on 2006/02/28 13:17:59 UTC

[users@httpd] Rewrite rules !!

Hello All,

I am newbie to rewrite rules. I am trying to redirect requests coming to http://domain.com/test/ to http://domain.com/test.php using below mod_rewrite rules in .htaccess. 

================================================
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/test/(.*)/(.*)/(.*)
RewriteRule ^/(.*) /test.php?cid=%1&pid=%2&type=%3 [L]

RewriteCond %{REQUEST_URI} ^/test/(.*)/(.*)
RewriteRule ^/(.*) test.php?cid=%1&pid=%2 [L]

RewriteCond %{REQUEST_URI} ^/test/(.*)
RewriteRule ^/(.*) test.php?cid=$1 [L]
================================================

Above rule does not seem to be working. Am I doing something wrong?

Any help would be appreciated.

Thank you,

Re: [users@httpd] Rewrite rules !!

Posted by Robert Ionescu <ro...@googlemail.com>.
Kunal wrote:
> Hello All,
> 
> I am newbie to rewrite rules. I am trying to redirect requests coming to http://domain.com/test/ to http://domain.com/test.php using below mod_rewrite rules in .htaccess. 

There is no leading slash in the rule pattern (left side) in .htaccess 
files, so you might try

RewriteRule ^test/([^/]+)/([^/]+)/(.*) /test.php?cid=$1&pid=$2&type=$3 [L]
RewriteRule ^test/([^/]+)/(.*) /test.php?cid=$1&pid=$2 [L]
RewriteRule ^test/(.*) /test.php?cid=$1 [L]


Remember the rule pattern is processed before the conditions are tested.

-- 
Robert

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org