Forum Moderators: phranque

Message Too Old, No Replies

changing a search form submission to static looking urls

involves htaccess

         

tqatsju

4:06 pm on May 27, 2005 (gmt 0)

10+ Year Member



ok here goes what i'm trying to do is change a form submission for a search like so

<form action="search_temp.php">
</form>

search_temp.php recieves a query string in this fashion
[blah.com...]

now what i would like to do is somehow change that url above to
search/keyword_radio/keyword.html

and then internally change it back to this which i think i have done right....
RewriteRule ^search/([^/]*)/([^/]*).html search.php?keyword_radio=$1&keyword=$2 [L]

so sort of a 2 part redirection, i understand the second part of it above, but i'm having trouble understanding how to get at query string variables, i've read some posts but i'm not sure i understand how you reference them....

jd01

7:08 pm on May 28, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi tqatsju,

I think your best bet is to use php to change your headers to the URL's you would like, then use mod_rewrite to serve the information. Without doing it this way I cannot think of a way to get what you would like without a 301, permanent move redirect. This could prove to be server intensive if your site is busy, and may not ultimately have the best effect on your SE rankings.

Using php for the header information (URL) would allow you to 'silently' or 'internally' serve the information from the php files without a redirect.

This can normally be accomplished by using php code at the top of your page and setting the header information there, before any html is displayed, or any other information is parsed.

This is very close:
RewriteRule ^search/([^/]*)/([^/]*).html search.php?keyword_radio=$1&keyword=$2 [L]

The only real changes are:
RewriteRule ^search/([^/]+)/([^.]+)\.html /search.php?keyword_radio=$1&keyword=$2 [L]

The change to + requires that there be at least one character that is not a / before the /. The change to .(dot) in the second expression makes it forward-looking, like I think you intended. The \. is to make sure the .(dot) is evaluated as a .(dot) and not 'any characer, except a line break'. Finally the / gives the full path to the file. (Unless, you know you don't need it.)

Hope this helps.

Justin

tqatsju

10:22 am on May 29, 2005 (gmt 0)

10+ Year Member



so you mean like using
header(location:"blah.com/search/$keyword_radio/$keyword.html")

in the search_temp.php file?

jd01

9:29 pm on May 29, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, exactly...

Then you can easily use mod_rewrite to serve the correct information to that location.

Justin