Forum Moderators: phranque

Message Too Old, No Replies

help with mod rewrite please

         

phpbilly

9:17 pm on Jun 21, 2010 (gmt 0)

10+ Year Member



Hi,

I was wondering if anyone could help, I have have a javascript dropdown that posts the variable directly in the url and I use the following modrewrite rule:

RewriteEngine on
RewriteRule ^test/([^/\.]+)/?$ page.php?variable=$1 [L]

This works fine. But when I now need to tackle the issue of when javascript is turned off, so I am using the get method and the following is displayed in the url:

http://localhost/site/test/?id=example1&submit1=submit

I have tried unsuccessfully to write a mod rewrite rule that would read

http://localhost/site/test/example1

in the browser.

Many thanks,

[edited by: jdMorgan at 1:09 pm (utc) on Jun 22, 2010]
[edit reason] Removed auto-linking for readability [/edit]

jdMorgan

1:20 pm on Jun 22, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Mod_rewrite does not "read" the browser, and mod_rewrite can't change the link in your on-page code which is what the browser will request (and show in its address bar while doing so), so I'm not sure what you're trying to do here.

Using PHP or server-side includes, you can generate the "localhost/site/test/example1" link for use in the <noscript> section in exactly the same form as you do in the JS code.

Understand that mod_rewrite works as a browser request comes into the server. It is not some kind of "HTML page editor" that works as the page is being output to the browser, and thus it cannot 'change the links' on your pages. It can only deal with incoming requests for the linked URLs that exist on your pages.

Jim

phpbilly

6:16 pm on Jun 22, 2010 (gmt 0)

10+ Year Member



Thanks for your explanation Jim, very helpful