homepage Welcome to WebmasterWorld Guest from 54.197.52.154
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
mod_rewrite issue
the rewrite rule not working
webon




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

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

 

jdMorgan




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

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

  • webon




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


    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

    webon




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


    should be [L]

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

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

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

    jdMorgan




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

    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

    webon




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

    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

    jdMorgan




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

    > 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

    webon




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

    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

    jdMorgan




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

    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

    Global Options:
     top home search open messages active posts  
     

    Home / Forums Index / Code, Content, and Presentation / Apache Web Server
    rss feed

    All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
    Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
    WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
    © Webmaster World 1996-2014 all rights reserved