You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Yashesh Bhatia <ya...@gmail.com> on 2008/04/08 13:48:03 UTC
[users@httpd] Extra trailing slash after the RewriteCond
Hello:
I'm trying to test the usage of RewriteCond and RewriteRule in
the
---------------------------------------------- vhost file
------------------------------------------
$ cat testredirect.conf
#
# test redirect sites
#
<VirtualHost 192.168.1.22:80>
ServerName www.redirectnew.com
DocumentRoot "/opt/httpd/htdocs/redirectnew"
<Directory "/opt/httpd/htdocs/redirectnew">
AllowOverride All
Order allow,deny
Allow from 192.168.1.
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.22:80>
ServerName www.redirectold.com
RewriteEngine On
RewriteOptions Inherit
RewriteCond %{HTTP_HOST} ^www.redirectold.com$ [NC]
RewriteRule ^(.*)$ http://www.redirectnew.com/$1 [R=301,L]
</VirtualHost>
$
------------------------------------------------------------------------------------
The above works perfectly fine except that it adds an extra trailing
slash to the redirected url
so if i type
http//www.redirectold.com
or http//www.redirectold.com/
it gets redirected to
http//www.redirectnew.com
Any fix for this.
Thanks.
Yashesh
---------------------------------------------------------------------
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] Re: Extra trailing slash after the RewriteCond
Posted by Eric Covener <co...@gmail.com>.
On Tue, Apr 8, 2008 at 9:35 AM, Yashesh Bhatia <ya...@gmail.com> wrote:
> Narendra:
>
> Hello, I tried the suggested fix but that did not work :(.
You're rule clearly captures the leading slash but then adds an
additional one before using the backreferece. Try doing more
investigation and looking at RewriteLog.
--
Eric Covener
covener@gmail.com
---------------------------------------------------------------------
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] Re: Extra trailing slash after the RewriteCond
Posted by Yashesh Bhatia <ya...@gmail.com>.
Narendra:
Hello, I tried the suggested fix but that did not work :(.
Thanks.
Yashesh
On Tue, Apr 8, 2008 at 6:42 PM, Narendra Verma
<na...@impetus.co.in> wrote:
> RewriteRule ^(.*)$ http://www.redirectnew.com/$1
>
> Replace it by
>
>
> RewriteRule ^(.*)$ http://www.redirectnew.com$1
>
> May solve your problem.
>
> Narendra
>
>
---------------------------------------------------------------------
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] Re: Extra trailing slash after the RewriteCond
Posted by Narendra Verma <na...@impetus.co.in>.
RewriteRule ^(.*)$ http://www.redirectnew.com/$1
Replace it by
RewriteRule ^(.*)$ http://www.redirectnew.com$1
May solve your problem.
Narendra
-----Original Message-----
From: Yashesh Bhatia [mailto:yasheshb@gmail.com]
Sent: Tuesday, April 08, 2008 6:39 PM
To: users@httpd.apache.org
Subject: [users@httpd] Re: Extra trailing slash after the RewriteCond
Sorry that should read
The above works perfectly fine except that it adds an extra trailing
slash to the redirected url so if i type
http//www.redirectold.com
or http//www.redirectold.com/
it gets redirected to
http//www.redirectnew.com//
Thanks.
Yashesh Bhatia
On Tue, Apr 8, 2008 at 5:18 PM, Yashesh Bhatia <ya...@gmail.com> wrote:
> Hello:
>
> I'm trying to test the usage of RewriteCond and RewriteRule in
> the
>
> ---------------------------------------------- vhost file
> ------------------------------------------
> $ cat testredirect.conf
> #
> # test redirect sites
> #
> <VirtualHost 192.168.1.22:80>
> ServerName www.redirectnew.com
> DocumentRoot "/opt/httpd/htdocs/redirectnew"
> <Directory "/opt/httpd/htdocs/redirectnew">
> AllowOverride All
> Order allow,deny
> Allow from 192.168.1.
> </Directory>
> </VirtualHost>
>
> <VirtualHost 192.168.1.22:80>
> ServerName www.redirectold.com
> RewriteEngine On
> RewriteOptions Inherit
> RewriteCond %{HTTP_HOST} ^www.redirectold.com$ [NC]
> RewriteRule ^(.*)$ http://www.redirectnew.com/$1 [R=301,L]
> </VirtualHost>
> $
>
----------------------------------------------------------------------------
--------
> The above works perfectly fine except that it adds an extra trailing
> slash to the redirected url
> so if i type
>
> http//www.redirectold.com
> or http//www.redirectold.com/
>
> it gets redirected to
> http//www.redirectnew.com
>
> Any fix for this.
>
> Thanks.
>
> Yashesh
>
---------------------------------------------------------------------
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
---------------------------------------------------------------------
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
[users@httpd] Re: Extra trailing slash after the RewriteCond
Posted by Yashesh Bhatia <ya...@gmail.com>.
Sorry that should read
The above works perfectly fine except that it adds an extra trailing
slash to the redirected url so if i type
http//www.redirectold.com
or http//www.redirectold.com/
it gets redirected to
http//www.redirectnew.com//
Thanks.
Yashesh Bhatia
On Tue, Apr 8, 2008 at 5:18 PM, Yashesh Bhatia <ya...@gmail.com> wrote:
> Hello:
>
> I'm trying to test the usage of RewriteCond and RewriteRule in
> the
>
> ---------------------------------------------- vhost file
> ------------------------------------------
> $ cat testredirect.conf
> #
> # test redirect sites
> #
> <VirtualHost 192.168.1.22:80>
> ServerName www.redirectnew.com
> DocumentRoot "/opt/httpd/htdocs/redirectnew"
> <Directory "/opt/httpd/htdocs/redirectnew">
> AllowOverride All
> Order allow,deny
> Allow from 192.168.1.
> </Directory>
> </VirtualHost>
>
> <VirtualHost 192.168.1.22:80>
> ServerName www.redirectold.com
> RewriteEngine On
> RewriteOptions Inherit
> RewriteCond %{HTTP_HOST} ^www.redirectold.com$ [NC]
> RewriteRule ^(.*)$ http://www.redirectnew.com/$1 [R=301,L]
> </VirtualHost>
> $
> ------------------------------------------------------------------------------------
> The above works perfectly fine except that it adds an extra trailing
> slash to the redirected url
> so if i type
>
> http//www.redirectold.com
> or http//www.redirectold.com/
>
> it gets redirected to
> http//www.redirectnew.com
>
> Any fix for this.
>
> Thanks.
>
> Yashesh
>
---------------------------------------------------------------------
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