Forum Moderators: phranque

Message Too Old, No Replies

Rewritting user url to friendly url

         

myrtleshine

10:01 am on Oct 21, 2011 (gmt 0)

10+ Year Member



Hi, been trying this for hours,

i have created a htaccess that direct my

[wexample.com...] to wwww.example.com/page.php?id=5

RewriteRule ^board/top100/?$ page.php?id=5 [NC,L]

and it beautifuklly display my website
however how do i enable user who key in
wwww.example.com/page.php?id=5 to display [wexample.com...] as my url? isit even possible?

*noob to SEO

lucy24

11:12 am on Oct 21, 2011 (gmt 0)

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



Can you say that again, using www.example.com ? All other names turn into clickable URLs and then we can't see what you typed.

But before you post again, do a Forums search for the phrase "query string". Or just scan the last 10 or 20 threads in this forum. The question comes up several times a week, so you do not need to search very long.

g1smd

6:51 pm on Oct 21, 2011 (gmt 0)

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



So far you have a RewriteRule configured as a rewrite which accepts a request for the friendly URL and rewrites that request to fetch content from an internal path and file with parameters passed to it.

You now need another RewriteRule, this time configured as a redirect. It needs a RewriteCond to test %{THE_REQUEST} to ensure that only parameters seen as part of an external request (and not as the result of a previous internal rewrite) are redirected. The RewriteRule will redirect the requests to the correct URL. The target will contain the protocol and domain name, and the rule will use the [R=301,L] flags.

The RewriteCond is needed to ensure you do not create an infinite loop.

Since this question comes up several times per week, and has done so for many years, there are very many prior code examples here.