httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chris Evens" <Chris.Ev...@christianrecord.org>
Subject RE: help with rewrites - changing the base path
Date Wed, 17 Dec 2008 22:03:48 GMT
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


Mime
View raw message