Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite and the back button

         

djohnson

10:59 pm on Nov 22, 2004 (gmt 0)

10+ Year Member



I am updating my main site to be more spider friendly, basically taking my php site and rewriting them to be shown as directories. Here is my .htaccess file:

RewriteEngine on
Options +FollowSymLinks

RewriteBase /

#Rules
RewriteRule ^dir/$ [sitename.com...]

When I place the .htaccess in my root directory, www.sitename.com/dir/ -> www.sitename.com/file.php?name=X&type=Y&place=Z. However, when I click the back button, it says the page cannot be found! I have been searching on google and this site this afternoon and can find nothing. Anyone have any ideas? Thanks!

djohnson

11:45 pm on Nov 22, 2004 (gmt 0)

10+ Year Member



Nevermind, bad cache in all 3 browsers I was testing it. I went home and now it is working fine on both computers, windows & mac. Oh well! :)

jdMorgan

12:39 am on Nov 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



djohnson,

There's another problem, and that is that you code is probably doing an external redirect, thus rendering your efforts to get spiders to list more-friendly URLs moot.

You need to use the internal rewrite mode of mod_rewrite: which looks like this:

RewriteRule ^dir/$ /file.php?name=X&type=Y&place=Z [L]

The difference is that only a local URL-path is used, rather than a canonical URL.

Also, check out the back-referencing feature of mod_rewrite. It will allow you to "copy parameters" from the requested URL into the new one. If you find yourself creating dozens of rules to create the hard-coded query-strings, this can be useful.

Jim