Forum Moderators: phranque

Message Too Old, No Replies

Rewriting URLs to make them “clean”

clean URLs - nothing after "?"

         

smallcompany

5:16 am on Jan 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Existing URLs are like this:

…site.com/?var1=A&var2=B&var3=C

or

…site.com/page.html?var1=A&var2=B&var3=C

or

…site.com/subfolder/page.html?var1=A&var2=B&var3=C

can I rewrite them through .htaccess so they are seen by search engines without variables while my server continues passing them from page to page and out like it does now? Can clean URL be achieved in this way?

Thanks

jdMorgan

4:29 pm on Jan 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The link on your page, which is what the client browser will request from your server, must contain all of the information needed to "re-build" the correct server filepath neede to reach or generate the proper content for that linked page.

So the short answer is "no," because the server would have no idea of what content was being requested if you dropped the *information* previously carried by the query string.

You can, however, publish the URL in a different form, such as

example.com/subfolder/page-A-B-C

or similar, and then internally rewrite that back to

example.com/subfolder/page.html?var1=A&var2=B&var3=C

inside your server, so that the scripts on your server will still work properly.
(This assumes that the three variables are always in the same order, by the way).

Jim

smallcompany

6:30 pm on Jan 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks for reply.

In this case we have static HTML pages, so variables do not influence the content in any way. All of the variables are like keywords, search engine or other referring URLs, click time, etc. Based on this, with, or without variables, the landing page will be the same.
That is why I thought I could make a statement in .htaccess which would “hide” variables. The way how it works now is that they are attached to the URL and that parser (written in Perl) parses HTML in order to insert them into all links (internal and outgoing). The final result is that we get those variables out and see them when a sale happens.
I am thinking about having a cookie instead of attaching everything to the URL, but thought we should test URL rewriting as well.

Thanks

jdMorgan

11:05 pm on Jan 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Once the request arrives at your server to be processed by mod_rewrite, it's too late to 'hide' anything, I'm afraid... It is the publishing of links on your pages that 'defines' the URL for all the world to see.

Mod_rewrite executes after a link is clicked and the request for that URL arrives at your server; mod_rewrite can redirect to a new URL, or rewrite an incoming URL to a non-default filepath, but is has no effect on the 'output' content of your pages.

Jim