Forum Moderators: phranque

Message Too Old, No Replies

Mod rewrite issue

mod_rewite issue

         

kselva

10:04 am on Jan 4, 2010 (gmt 0)

10+ Year Member



I have linux vps in which in installed Apache/2.0.63 and enabled redirection with .htaccess file. The example configuration is:

RewriteCond %{REQUEST_URI} airport-loc-(.+)\.html$
RewriteRule ^(.*)$ http://example.com/airport-loc.php?country=$1 [L]

The redirection is working but in the browser the url is shown instead of hiding.Example if i click the link [mysite.com...] browser the url is shown as http://example.com/aireport-loc.php?country=test instead of http://example.com/aireport-loc-test.html. How can i solve this issue? The same was working fine my cpanel vps in which i have hosted my site previously

[edited by: jdMorgan at 2:38 pm (utc) on Jan. 4, 2010]
[edit reason] example.com [/edit]

jdMorgan

2:36 pm on Jan 4, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The example is incorrect in three ways:

First, it is inefficiently-coded, second, the syntax used in the substitution specifies an 302 URL-to-URL redirect instead of an internal URL-to-filepath rewrite, and third, there is an error in the back-reference which would cause the entire requested URL to appear as the "country" in the query string.

A more-efficient and correct coding would be the single line:


RewriteRule ^airport-loc-(.+)\.html$ airport-loc.php?country=$1 [L]

Jim