Welcome to WebmasterWorld Guest from 54.227.231.144

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

help needed for rewrite

I get /foo?q=widget instead of /widget

   
7:28 pm on Feb 26, 2008 (gmt 0)

5+ Year Member



I have a website where dynamic URLs are rewritten to more friendly ones like:
mysite.com/index.php?q=foo becomes mysite.com/foo.
The rewrite is as follows: RewriteRule ^(.*)$ /?q=$1 [L]

It works perfectly well, i.e., the mysite.com/foo retrieves the the database entry "foo" (a dictionary entry).

But the "foo" page contains some hyperlinks to other entries, say to "widget," and when the page is retrieved, the link to widget becomes:

mysite.com/foo?q=widget

Is there a way to eliminate this self referencing (foo?q=) and have only the widget (mysite.com/widget) when the widget link on the foo page is clicked?

Thank you in advance.

2:42 pm on Feb 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It should be possible by modifying your programming.

In your database, instead of having the links as <a href="/index.php?q=varId"> have them as <a href="/varId">.

The mod_rewrite does not rewrite url's coming from the database, it only interprets one URL and matches it with another - but you have to point it to the right match.