Forum Moderators: phranque
what i have is www.site.com/cart/cart.php
what i want to show up is www.site.com.
however i don't want to redirect from www.site.com/cart/cart.php to www.site.com I just want it to appear that way to the end user.
Can anyone help? thanks.
The usual technique involves three steps:
1) Change the URLs in the links on your pages to the form you want displayed in the browser.
2) Internally rewrite those URLs, when received in requests by your server, to the form needed to locate and serve the appropriate content.
3) Externally redirect the "unwanted-format" URLs to the form you want displayed in browsers and indexed by search engines (optional).
PHP's preg_replace is particularly useful for the first step, unless you find it easier to update your database.
mod_rewrite can be used to do the internal rewrites for step two and the external redirects for step three.
The third step is a bit tricky, since you must test the server variable %{THE_REQUEST} and redirect only direct client requests for the "unwanted" URLs; Otherwise, step two and three together will create an 'infinite' rewrite/redirect loop.
Note that a successful implementation of this method requires that both forms of the URL contain all of the information needed to derive/create the other form.
Jim