You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by thomas Armstrong <ta...@gmail.com> on 2007/09/10 11:18:39 UTC

[users@httpd] How to mask an URL with .htaccess

 Hi.

I want to make http://mysite.com/post/004.htm -->
http://mysite.com/post.php?id=004
but not redirecting but masking the URL (the first URL must be shown
and not the second one).

My .httaccess:
--------------------------
RewriteEngine On
RewriteBase /
DirectoryIndex index.php index.html
RewriteRule ^post/(.*).htm post.php?id=$1 [R=301,L]
---------------------------

I also tried with:
RewriteRule ^post/(.*).htm post.php?id=$1 **whithout R,L**
I got this URL: http://mysite.com/post.php/005.htm?id=005

I also tried with
RewriteRule ^post/(.*).htm post.php?id=$1 [L]
I got this URL: http://mysite.com/post.php?id=005

I also tried with
RewriteRule ^post/(.*).htm http://mysite.com/post.php?id=$1 [L]
I got this URL: http://mysite.com//post.php/005.htm?id=005

Any suggestion?

---------------------------------------------------------------------
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


Re: [users@httpd] How to mask an URL with .htaccess

Posted by Vincent Bray <no...@gmail.com>.
On 10/09/2007, thomas Armstrong <ta...@gmail.com> wrote:
> I want to make http://mysite.com/post/004.htm -->
> http://mysite.com/post.php?id=004
> but not redirecting but masking the URL (the first URL must be shown
> and not the second one).
>
> My .httaccess:
> --------------------------
> RewriteEngine On
> RewriteBase /
> DirectoryIndex index.php index.html
> RewriteRule ^post/(.*).htm post.php?id=$1 [R=301,L]
> ---------------------------

Clearly you don't want this one as [R] does the opposite of what you're asking.

> I also tried with:
> RewriteRule ^post/(.*).htm post.php?id=$1 **whithout R,L**
> I got this URL: http://mysite.com/post.php/005.htm?id=005
>
> I also tried with
> RewriteRule ^post/(.*).htm post.php?id=$1 [L]
> I got this URL: http://mysite.com/post.php?id=005

These two look fine. If the browser is still being redirected, it
could be that your script is doing the redirect. One way to tell would
be to watch the http headers during the redirect and see if php
advertises itself (x-Powered-By or whatever it is) on the 3xx
response.

http://wiki.apache.org/httpd/WatchingHttpHeaders

> I also tried with
> RewriteRule ^post/(.*).htm http://mysite.com/post.php?id=$1 [L]
> I got this URL: http://mysite.com//post.php/005.htm?id=005

This one is equivalent to the first, because using a full url in the
target implies a 3xx redirect.

-- 
noodl

---------------------------------------------------------------------
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