You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Matthew Sacks <nt...@gmail.com> on 2008/12/15 23:54:28 UTC
help with rewrites - changing the base path
i am trying to change the base path of a directory to rewrite to a new
location, there are no files in the location, so it is just a
cosmetic/seo change.
i have some rewrites that are put in place by my hosting provider, and
im having some difficulty getting the rewrite to work:
here is my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /techblog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^/techblog /technology-blog [L]
RewriteRule . /techblog/index.php [L]
</IfModule>
# END WordPress
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: help with rewrites - changing the base path
Posted by Chris Evens <Ch...@christianrecord.org>.
Matthew
This works as if you just moved all the data files to a new directory.
To keep this change internal you can drop the [R=301] in the brackets and
just use the [L] character.
Also as I am assuming that the rest of the URL is to be arguments that is
where the regular expression comes into play
The (.*)$ portion of the expression is telling modrewrite to make variables
of the rest of the URL. In this instance it is taking the rest of the URL and
making it argument $1. This is where the second half of your rewriterule
comes into play. You always need to point the server to an actual file. What
that file serves may be dependent upon what is in the URL. By using a static
URL you disguise what the variable names that are used on the actual page to
make variable pages from one served page.
An example that I am currently testing and is working is
RewriteBase /
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
RewriteRule ([A-Za-z0-9-\ ]+)/([A-Za-z0-9-\ /_]+).php$
$2.php?[variable name]=$1 [QSA,PT]
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-d
RewriteRule ([A-Za-z0-9-\ /_]+).php$ [dynamic page file]?[variable
name]=$1 [QSA,PT,L]
Let me know if this is enough for you
Christopher Evens
Web Programmer, Christian Record Services for the Blind
Free lending library for the blind
www.christianrecord.org
-----Original Message-----
From: ntwrkd [mailto:ntwrkd@gmail.com]
Sent: Wednesday, December 17, 2008 1:51 PM
To: users@httpd.apache.org
Subject: RE: help with rewrites - changing the base path
Thanks Chris,
I will give this a shot. I wouldn't have discoveretd this in the docs.
Does this require that the directory /technology-blog be present, or is it a
cosmetic change only?
Chris Evens wrote:
>
> Matthew
> Is this more like a directory name change if so all you need is
>
> RewriteRule ^/techblog(.*)$ /technology-blog$1 [R=301,L]
>
> R is the browser return code and also forces the users browser to refresh.
> It
> is also possible to make this transfer internally without a response to
> the
> users browser but sending the return code does tell the browser to update
> its
> bookmarks.
>
> Christopher Evens
> Web Programmer, Christian Record Services for the Blind
> Free lending library for the blind
> www.christianrecord.org
>
>
>
> -----Original Message-----
> From: Matthew Sacks [mailto:ntwrkd@gmail.com]
> Sent: Monday, December 15, 2008 4:54 PM
> To: users@httpd.apache.org
> Subject: help with rewrites - changing the base path
>
> i am trying to change the base path of a directory to rewrite to a new
> location, there are no files in the location, so it is just a
> cosmetic/seo change.
>
> i have some rewrites that are put in place by my hosting provider, and
> im having some difficulty getting the rewrite to work:
>
>
> here is my .htaccess file:
>
> # BEGIN WordPress
> <IfModule mod_rewrite.c>
> RewriteEngine On
>
> RewriteBase /techblog/
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> #RewriteRule ^/techblog /technology-blog [L]
> RewriteRule . /techblog/index.php [L]
>
>
> </IfModule>
>
> # END WordPress
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
>
--
View this message in context:
http://www.nabble.com/help-with-rewrites---changing-the-base-path-tp21023859p
21060112.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: help with rewrites - changing the base path
Posted by ntwrkd <nt...@gmail.com>.
Thanks Chris,
I will give this a shot. I wouldn't have discoveretd this in the docs.
Does this require that the directory /technology-blog be present, or is it a
cosmetic change only?
Chris Evens wrote:
>
> Matthew
> Is this more like a directory name change if so all you need is
>
> RewriteRule ^/techblog(.*)$ /technology-blog$1 [R=301,L]
>
> R is the browser return code and also forces the users browser to refresh.
> It
> is also possible to make this transfer internally without a response to
> the
> users browser but sending the return code does tell the browser to update
> its
> bookmarks.
>
> Christopher Evens
> Web Programmer, Christian Record Services for the Blind
> Free lending library for the blind
> www.christianrecord.org
>
>
>
> -----Original Message-----
> From: Matthew Sacks [mailto:ntwrkd@gmail.com]
> Sent: Monday, December 15, 2008 4:54 PM
> To: users@httpd.apache.org
> Subject: help with rewrites - changing the base path
>
> i am trying to change the base path of a directory to rewrite to a new
> location, there are no files in the location, so it is just a
> cosmetic/seo change.
>
> i have some rewrites that are put in place by my hosting provider, and
> im having some difficulty getting the rewrite to work:
>
>
> here is my .htaccess file:
>
> # BEGIN WordPress
> <IfModule mod_rewrite.c>
> RewriteEngine On
>
> RewriteBase /techblog/
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> #RewriteRule ^/techblog /technology-blog [L]
> RewriteRule . /techblog/index.php [L]
>
>
> </IfModule>
>
> # END WordPress
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>
>
--
View this message in context: http://www.nabble.com/help-with-rewrites---changing-the-base-path-tp21023859p21060112.html
Sent from the Apache HTTP Server - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: help with rewrites - changing the base path
Posted by Chris Evens <Ch...@christianrecord.org>.
Matthew
Is this more like a directory name change if so all you need is
RewriteRule ^/techblog(.*)$ /technology-blog$1 [R=301,L]
R is the browser return code and also forces the users browser to refresh. It
is also possible to make this transfer internally without a response to the
users browser but sending the return code does tell the browser to update its
bookmarks.
Christopher Evens
Web Programmer, Christian Record Services for the Blind
Free lending library for the blind
www.christianrecord.org
-----Original Message-----
From: Matthew Sacks [mailto:ntwrkd@gmail.com]
Sent: Monday, December 15, 2008 4:54 PM
To: users@httpd.apache.org
Subject: help with rewrites - changing the base path
i am trying to change the base path of a directory to rewrite to a new
location, there are no files in the location, so it is just a
cosmetic/seo change.
i have some rewrites that are put in place by my hosting provider, and
im having some difficulty getting the rewrite to work:
here is my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /techblog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^/techblog /technology-blog [L]
RewriteRule . /techblog/index.php [L]
</IfModule>
# END WordPress
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Re: help with rewrites - changing the base path
Posted by Bob Ionescu <bo...@googlemail.com>.
2008/12/29 Matthew Sacks <nt...@gmail.com>:
> I cleared all rewrites so all I have is the following:
> RewriteRule ^/techblog(.*)$ http://www.foo.com/$1 [R=301]
If you're using this in per-dir context (e.g. in .htaccess files)
reachable via http://www.example.com/.htaccess, strip the leading
slash of the pattern: ^techblog(.*)$ and don't forget to enable the
engine via RewriteEngine on.
Bob
---------------------------------------------------------------------
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] Getting the following error: image/gif (NS_IMAGELIB_ERROR_LOAD_ABORTED)
Posted by "Kamaraj, Jayakumar" <jk...@corp.untd.com>.
Hi,
Sorry for the mistake. The image is present in the local server ,but the server report the error HTTP/1.0 403 Forbidden.
Thanks,
jai
-----Original Message-----
From: Kamaraj, Jayakumar [mailto:jkamaraj@corp.untd.com]
Sent: Wednesday, December 31, 2008 2:01 PM
To: users@httpd.apache.org
Subject: [users@httpd] Getting the following error: image/gif
(NS_IMAGELIB_ERROR_LOAD_ABORTED)
Hi,
When I request for a particular image from the server , sometimes it is returning the image, sometimes it is returning this error message (image/gif (NS_IMAGELIB_ERROR_LOAD_ABORTED) -this one I obtained using httpfirefox plugin of firefox)
What may be the reasons. Please urgent, reply asap.
Thanks,
jai
---------------------------------------------------------------------
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] Getting the following error: image/gif (NS_IMAGELIB_ERROR_LOAD_ABORTED)
Posted by "Kamaraj, Jayakumar" <jk...@corp.untd.com>.
Hi,
When I request for a particular image from the server , sometimes it is returning the image, sometimes it is returning this error message (image/gif (NS_IMAGELIB_ERROR_LOAD_ABORTED) -this one I obtained using httpfirefox plugin of firefox)
What may be the reasons. Please urgent, reply asap.
Thanks,
jai
---------------------------------------------------------------------
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: help with rewrites - changing the base path
Posted by Matthew Sacks <nt...@gmail.com>.
hi list,
new problem:
when i try to add a rewrite just for the base url, it doesn't work and
appends the destination url twice and ends up as a 404:
how can i accommodate the wild-card and the base path (RewriteRule ^/$
http://www.foobar.com)?
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /techblog
RewriteRule ^/$ http://www.foobar.com
RewriteRule /about http://www.foobar.com/about [R=301]
RewriteRule /(.*)$ http://www.foobar.com/$1 [R=301]
On Mon, Dec 29, 2008 at 3:03 PM, Eric Covener <co...@gmail.com> wrote:
> On Mon, Dec 29, 2008 at 5:53 PM, André Warnier <aw...@ice-sa.com> wrote:
>> Hi.
>>
>> Am I interpreting this correctly, that the .htaccess file you are talking
>> about, is the one that is in the original /techblog location ?
>>
>> If so, and without taking my word for it, isn't it so for a RewriteRule that
>> is in a .htaccess file in such a location "/techblog", that the original URL
>> you are comparing against already has the "/techblog" prefix removed ?
>> (because you are "already there" so to speak)
>>
>> Maybe you want to try this instead :
>>
>> RewriteRule /(.*)$ http://www.foo.com/$1 [R=301]
>
> in techblog/.htaccess, "/techblog/" is removed, including the trailing slash.
>
> --
> 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
>
>
---------------------------------------------------------------------
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: help with rewrites - changing the base path
Posted by Eric Covener <co...@gmail.com>.
On Mon, Dec 29, 2008 at 5:53 PM, André Warnier <aw...@ice-sa.com> wrote:
> Hi.
>
> Am I interpreting this correctly, that the .htaccess file you are talking
> about, is the one that is in the original /techblog location ?
>
> If so, and without taking my word for it, isn't it so for a RewriteRule that
> is in a .htaccess file in such a location "/techblog", that the original URL
> you are comparing against already has the "/techblog" prefix removed ?
> (because you are "already there" so to speak)
>
> Maybe you want to try this instead :
>
> RewriteRule /(.*)$ http://www.foo.com/$1 [R=301]
in techblog/.htaccess, "/techblog/" is removed, including the trailing slash.
--
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: help with rewrites - changing the base path
Posted by André Warnier <aw...@ice-sa.com>.
Hi.
Am I interpreting this correctly, that the .htaccess file you are
talking about, is the one that is in the original /techblog location ?
If so, and without taking my word for it, isn't it so for a RewriteRule
that is in a .htaccess file in such a location "/techblog", that the
original URL you are comparing against already has the "/techblog"
prefix removed ? (because you are "already there" so to speak)
Maybe you want to try this instead :
RewriteRule /(.*)$ http://www.foo.com/$1 [R=301]
Matthew Sacks wrote:
> I cleared all rewrites so all I have is the following:
> RewriteRule ^/techblog(.*)$ http://www.foo.com/$1 [R=301]
>
> I want http://www.bar.com/techblog/thisfile.html to be redirected to
> http://www.foo.com/thisfile.html
>
> I cant seem to get this to work. all I get is 404
>
> On Mon, Dec 15, 2008 at 2:54 PM, Matthew Sacks <nt...@gmail.com> wrote:
>> i am trying to change the base path of a directory to rewrite to a new
>> location, there are no files in the location, so it is just a
>> cosmetic/seo change.
>>
>> i have some rewrites that are put in place by my hosting provider, and
>> im having some difficulty getting the rewrite to work:
>>
>>
>> here is my .htaccess file:
>>
>> # BEGIN WordPress
>> <IfModule mod_rewrite.c>
>> RewriteEngine On
>>
>> RewriteBase /techblog/
>> RewriteCond %{REQUEST_FILENAME} !-f
>> RewriteCond %{REQUEST_FILENAME} !-d
>> #RewriteRule ^/techblog /technology-blog [L]
>> RewriteRule . /techblog/index.php [L]
>>
>>
>> </IfModule>
>>
>> # END WordPress
>>
>
> ---------------------------------------------------------------------
> 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: help with rewrites - changing the base path
Posted by Matthew Sacks <nt...@gmail.com>.
I cleared all rewrites so all I have is the following:
RewriteRule ^/techblog(.*)$ http://www.foo.com/$1 [R=301]
I want http://www.bar.com/techblog/thisfile.html to be redirected to
http://www.foo.com/thisfile.html
I cant seem to get this to work. all I get is 404
On Mon, Dec 15, 2008 at 2:54 PM, Matthew Sacks <nt...@gmail.com> wrote:
> i am trying to change the base path of a directory to rewrite to a new
> location, there are no files in the location, so it is just a
> cosmetic/seo change.
>
> i have some rewrites that are put in place by my hosting provider, and
> im having some difficulty getting the rewrite to work:
>
>
> here is my .htaccess file:
>
> # BEGIN WordPress
> <IfModule mod_rewrite.c>
> RewriteEngine On
>
> RewriteBase /techblog/
> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> #RewriteRule ^/techblog /technology-blog [L]
> RewriteRule . /techblog/index.php [L]
>
>
> </IfModule>
>
> # END WordPress
>
---------------------------------------------------------------------
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