Member Avatar for nova37

hello
i need little help with url rewriting

i have page :: www.mysite.com/search.php?q=something
desire url structure:: www.mysite.com/q/something

.htaccess code :: RewriteRule q/(.*) search.php?q=$1

the above htaccess code work fine but i have little more htaccess code for my site

.htaccess code :: RewriteRule www.(.*) web.php?url=$1
desire url structure:: www.mysite.com/www.daniweb.com

so now problem is when query is made like www.mysite.com/q/http://www.daniweb.com then parameter http://www.daniweb.com is sent to both htaccess code due to which two php pages mixup in othe another .
so please help so that /q/something is only sent to search.php

Member Avatar for nova37

i solved the [rblem finally and i will post is solution maybe it will help someone

problem ::
i have two rewrite rules

RewriteRule q/(.*) search.php?q=$1
RewriteRule www.(.*) web.php?url=$1

now if someone come to site and have url like : www.site.com/q/www.daniweb.com

i can see /q/www.daniweb.com and i want that it pass to search.php but in this case it will pass to both rules and as result two php pages (search.php and web.php) will open simultanenously which is not good becuase two pages open at once result one dirty page full of both pages results

so to avoid that problem we should skip one rule becuase we are only interested in search.php as parameters as passed as /q/www.daniweb.com

solution::

RewriteRule q/(.*) search.php?q=$1 [S=1]
RewriteRule www.(.*) web.php?url=$1

s=1 // # of rules u want to skip i want to skil web.php so i set s=1
that all :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.