Rewrite rule problem ( 7 Views )

no kitty!
  1. I have the following RewriteRules in an .htaccess file in the /html directory:

    Code:

    RewriteRule ^searchex/\?searchterms=([a-zA-Z0-9_]+) http://www.website.com/html/index.html?cmd=simplesearch&searchterms=$1 [L]
      RewriteRule ^searchresults/([0-9]+)/?([0-9]+)?/?([0-9]+)? http://www.website.com/html/index.html?cmd=dosearch&id=$1&page=$2&total=$3 [L]
      RewriteRule ^((search/?)|(searchresults/?)) http://www.website.com/html/index.html?search=1 [L]

    If I type in
    http://www.website.com/html/searchex/?searchterms=XYZ
    it takes me to
    http://www.website.com/html/index.html?search=1

    If I add a $ at the end of the third rule, like this:
    RewriteRule ^((search/?)|(searchresults/?))$ http://www.website.com/html/index.html?search=1

    and then try to go to
    http://www.website.com/html/searchex/?searchterms=XYZ
    I get a 404.

    Why is this happening? What is flawed about my first rule?

    (Atakan, Ethiopia)

  2. The query string is separated from the URL so you cannot check the content of the query string by using RewriteRule.
    You should use RewriteCond and check the env variable called QUERY_STRING.

    Here is an example:
    /html/.htaccess
    Code:

    RewriteEngine On

    RewriteCond %{QUERY_STRING} ^searchterms=([a-zA-Z0-9_]+)$
    RewriteRule ^searchex/?$ index.html?cmd=simplesearch [QSA,L]

    RewriteRule ^searchresults/([0-9]+)/?$ index.html?cmd=dosearch&id=$1 [L]

    RewriteRule ^searchresults/([0-9]+)/([0-9]+)/?$ index.html?cmd=dosearch&id=$1&page=$2 [L]

    RewriteRule ^searchresults/([0-9]+)/([0-9]+)/([0-9]+)/?$ index.html?cmd=dosearch&id=$1&page=$2&total=$3 [L]

    Don't understand wha you want to do here:
    > RewriteRule ^((search/?)|(searchresults/?)) http://www.website.com/html/index.html?search=1 [L]

    :)

    p.s.
    /html/ is it the main root or a subdir of your website ?

    (kenan yavuz, Cote D'Ivoire)

  3. Excellent, thanks for the help, that worked perfectly. :)

    For the second rule I'm saying if anyone decides to go to /html/search or /html/searchresults they should get directed to the search screen, since those directories don't actually exist.

    /html is a subdirectory.

    (Ersoy , Gibraltar)



Related Topics ... (or search in 1.720.883 topics !)

problem with rewrite rule (2)
rewrite rule problem? (4)
problem with rewrite rule (5)
problem with rewrite rule (9)
a rewrite rule problem (purple, monkey, dishwasher) (10)
home page rewrite rule dominates other rewrite rules (5)
mod-rewrite: confused with my rewrite rule. (6)
rewrite rule and %2 ??? (2)
help me with this rewrite rule (2)




copyright © 2007-2031 Pfodere.COM ( 5 Pfoyihuee Online )

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 
1.6083