Welcome to WebmasterWorld Guest from 54.198.93.179

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

mod_rewrite issue

the rewrite rule not working

     
6:52 pm on Jul 24, 2004 (gmt 0)

10+ Year Member



Hello

i have add the rewrite rule on .htaccess file. but when i try the links on page, still the same .

from
[mybusiness.com...]

to
[mybusiness.com...]

--------------------------
RewriteEngine on
RewriteBase /
RewriteRule /name1_([^-]*)_([^-]*)_(.*).html /name3.php\?id=$1&page=$2 [I]

-------------------------------------

thanks in advance

7:15 pm on Jul 24, 2004 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Your URL does not match the pattern -- The requested URL has two underscores, while the pattern requires three. In addition, it looks like you have mixed hyphnes and underscores in the pattern, and the [I] is not a valid mod_rewrite flag.

  • Apache mod_rewrite documentation [httpd.apache.org]
  • Apache URL Rewriting Guide [httpd.apache.org]
  • Regular Expressions Tutorial [etext.lib.virginia.edu]

    Jim

  • 8:53 pm on Jul 24, 2004 (gmt 0)

    10+ Year Member




    Hello

    when i tried to use the rule on server, but it just change nothing.

    i have checked the server configuration, and it seems installed the mod_rewrite already.

    can you help to see what is wrong on the code?

    any sample code for this rule will appeciate.

    PS:

    1. the second variable page will sometime has sometime don't.
    2. i use underscore "_" to separate the different parts due to there are product name may use "-" sometimes.

    -------------------------------------------------

    from
    [mybusiness.com...]

    to
    [mybusiness.com...]

    --------------------------
    RewriteEngine on
    RewriteBase /
    RewriteRule /name1_([^-]*)_(.*).html /name1.php\?id=$1&page=$2 [I]

    -------------------------


    many thanks

    webon

    8:54 pm on Jul 24, 2004 (gmt 0)

    10+ Year Member




    should be [L]

    --------------------------
    RewriteEngine on
    RewriteBase /
    RewriteRule /name1_([^-]*)_(.*).html /name1.php\?id=$1&page=$2 [L]

    -------------------------

    otherwise, the [i] will cause the server error.

    9:30 pm on Jul 24, 2004 (gmt 0)

    WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



    Again, you have a "-" in your pattern, where a "_" is needed. See the Regular Expressions tutorial [webmasterworld.com] for more information on creating correct RewriteRule patterns.

    Rewrite example.com/name1_product-name_2.html to example.com/foldname/name1.php?id=product-name&page=2


    RewriteRule ^name1_([^_]+)_([^.]+)\.html$ /foldname/name1.php?id=$1&page=$2 [L]

    Jim
    9:24 pm on Jul 27, 2004 (gmt 0)

    10+ Year Member



    again

    from
    [mydomain.com...]

    to
    [mydomain.com...]

    RewriteEngine on
    RewriteBase /
    RewriteRule ^product_([^_]+)_([^.]+)\.html$ /foldname/product.php?Type=$1&page=$2 [L]

    i have upload the .htaccess file on my unix server, file is under html fold, and everything also under html fold. When i browser the page and try the links on page, it doesn't change at all.

    1. the unix server for sure installed the mod_rewrite
    and i don't think some wrong with the code.

    2. is there still anything i missing here?

    many thanks.

    webon

    11:36 pm on Jul 27, 2004 (gmt 0)

    WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



    > When i browser the page and try the links on page, it doesn't change at all.

    Are you expecting the address in the browser address bar to change? That is not what this rule does. This rule tells the server to pass requests for the product_typename_1.html URL in your browser address bar to the product.php script, with the variables in the proper order.

    Do you have *any* other working rewriterules? If not, you may want to try something simple first, rather than trying this somewhat 'advanced' rewrite to a script.

    Do you have a simple 'index.html' page or something like it? If so, try a rule like this:


    RewriteEngine on
    Options +FollowSymLinks
    RewriteRule ^silly\.html$ /index.html [L]

    Now use your browser to request the page "silly.html", a page which does not exist on your server. The rewriterule should tell your server to return the contents of your "index.html" page.

    Jim

    12:29 am on Jul 28, 2004 (gmt 0)

    10+ Year Member



    Jd

    thanks for the post.

    i have tried LinkFreeze before, thought may have the same way to modify url.

    and tried the sample code, it works.

    sorry to post such silly question, i am total new on apache. now getting step forward...

    webon

    1:29 am on Jul 28, 2004 (gmt 0)

    WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



    Hmmm...

    Try adding


    Options +FollowSymLinks

    to the rewrite code you posted in message number 6 above. Then test by accessing http://www.mydomain.com/product_typename_1.html

    Jim

     

    Featured Threads

    Hot Threads This Week

    Hot Threads This Month