• I wanted to know the syntax to be used in the .htaccess file for making clean url for the printer-friendly pages. eg.

    if the rewrite base is /wp/ in the .htaccess file, and the print.php is at /wp/,

    what should be the syntax to be used in the .htaccess file if the url:

    http://www.domainxyzzz.org/wp/print.php?p=72

    has to be converted into

    http://www.domainxyzzz.org/print/72/

    I have searched the wordpress forum, but couldn’t find any solution; while the tutorial sites on .htaccess were a bit difficult to understand. thanks.

    Anup

Viewing 7 replies - 1 through 7 (of 7 total)
  • RewriteRule ^/print/([0-9]*) /wp/print.php?p=$1
    or something.

    Thread Starter anup

    (@anup)

    this doesn’t seem to work. perhaps something is missing ?

    Hmm. This works on my site:

    RewriteRule ^([0-9]+)/print/?$ /print.php?p=$1 [QSA,L]

    But this doesn’t:

    RewriteRule ^print/([0-9]+)/?$ /print.php?p=$1 [QSA,L]

    They are identical except for the swap of ‘print/’ and the regex for the post id. I can’t say why the latter fails.

    And this works:

    RewriteRule ^printme/([0-9]+)/?$ /print.php?p=$1 [QSA,L]

    I think there’s a conflict with the ‘print’ filename, but can’t say why.

    Thread Starter anup

    (@anup)

    Many thanks for that. It really works. But an additional help is required.

    In my index page, I have defined the print page to be

    http://www.i3pep.org/wp/print.php?p=<?=the_ID()?>

    Consequently, the URL comes to be like:

    http://www.i3pep.org/wp/print.php?p=72

    while this same thing can be accessed as:

    http://www.i3pep.org/print-version/72/

    I am using the following in .htaccess:

    RewriteRule ^print-version/([0-9]+)/?$ /print.php?p=$1 [QSA,L]

    The question is, how to make the “clean url” show up?

    What changes do I need to make ?

    tia.

    – Anup

    Just change the url component in your template to:

    <?php bloginfo('siteurl'); ?>/print-version/<?php the_ID(); ?>/

    WordPress should take of the rest.

    Thread Starter anup

    (@anup)

    Wow! This is really great! Many thanks once again !

    Anup

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘clean url for printer-friendly page’ is closed to new replies.