httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Pasher <just...@newmediagateway.com>
Subject Re: [users@httpd] Problem with Mod_Rewrite
Date Tue, 14 Apr 2009 20:03:51 GMT
ricardo13 wrote:
> Hi all,
>
> I have other doubt about mod_rewrite.
>
> Have this line in httpd.conf:
>
> RewriteEngine on
> RewriteRule ^/index/([0-9]+)/$ /index.html?id=$1
>
> When type "http://localhost/index.html?id=11" it doesn't show URL
> "http://localhost/index/11/"
> I saw this example in a site.
>   

The rewrite rule is backwards for your situation. This will (internally) 
rewrite the URL http://localhost/index/11/ into 
http://localhost/index.html?id=11. If the end user visits the latter URL 
directly, the rewrite rule won't apply. If you want to change 
http://localhost/index.html?id=11 into http://localhost/index/11/, you 
have to reverse the rewrite rule. However, you'll have to break out the 
query string into a RewriteCond directive, as the RewriteRule directive 
does not include the query string. Something like this (I can't remember 
the exact syntax for query string checking off the top of my head, so 
this might be a little off).

RewriteCond ${QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^/index.html$ /index/%1/

-- 
Justin Pasher

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message