Forum Moderators: phranque

Message Too Old, No Replies

Can I use mod rewrite to do this?

Rewriting http://domain.com/?id=greenwidget into......

         

DynamicNiches

6:22 pm on Jun 12, 2008 (gmt 0)

10+ Year Member



I know that you can use mod_rewrite to rewrite php pages into static html form.

Can you use mod_rewrite to do this though?

Original URL: [domain.com...]

Can mod_rewrite change this URL into something like this:

New URL: [domain.com...] ?

Let me also tell you that the /?id=greenwidget variable dislplays content on the current webpage. If mod_rewrite can do this will the variable "greenwidget" still be displayed on the web page?

[edited by: DynamicNiches at 6:27 pm (utc) on June 12, 2008]

jdMorgan

7:11 pm on Jun 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mod_rewrite does not change the links on your pages. mod_rewrite acts after a URL request arrives at your server, and before any content is served or any scripts are executed. It can either modify the filepath associated with the requested URL, or generate an external redirect to a different URL, requesting the client to re-request the resource it wants from a different URL. It can do other things as well, not relevant to this discussion.

What you're likely wanting to do is this:

1) Put links to example.com/greenwidget.html on your pages (perhaps by using an "SEF plug-in", or manually)

2) Use mod_rewrite to internally rewrite requests for the URL-path /greenwidget.html, when received by your server, to the filepath /?id=greenwidget

3) An optional clean-up step is to 301-redirect direct client requests for the URL to the URL http://example.com/greenwidget.html

The first two steps are required. The last simply speeds up search engine listing updates, and 'recovers' old user bookmarks and incoming links.

Note the use of the words "rewrite" and "redirect" and how they affect URLs and filepaths.

All covered in this previous thread [webmasterworld.com].

Jim