Forum Moderators: phranque

Message Too Old, No Replies

htaccess redirect from folder with space in name

         

bunk58

3:35 pm on Aug 10, 2007 (gmt 0)

10+ Year Member



I've looked through the posts but can't find or missed the solution to my problem.
We moved some files and pages from site A to site B (example.com).
I currently have an HTML redirect page for each of the old ones.
Ideally I would like a 301 Redirect for the individual pages.
The problem is the folder that had the moved pages in is named Flash Studio, with a space.
I have tried several versions :

redirect 301 /Flash Studio/ http://www.example.com/

redirect 301 /Flash%20Studio/ http://www.example.com/

redirect 301 /Flash\ Studio/ http://www.example.com/

but either I get a 500 error or they don't redirect.
Is there a way to get htaccess to work with the space in the folder name?
My existing htaccess file without all the commented out bits is:

php_flag zlib.output_compression On
php_value zlib.output_compression_level 5
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

[edited by: jdMorgan at 5:35 pm (utc) on Aug. 11, 2007]
[edit reason] example.com [/edit]

bunk58

9:29 am on Aug 11, 2007 (gmt 0)

10+ Year Member



To answer my own question :

redirect 301 "/Flash Studio/cfslit/cfslit.htm" http://www.example.com/index.html?

[edited by: jdMorgan at 5:36 pm (utc) on Aug. 11, 2007]
[edit reason] example.com [/edit]

jdMorgan

5:44 pm on Aug 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The other way to do it is to use mod_alias' RedirectMatch directive, so that the regular-expressions-escaped space will be recognized.

Be aware that using two different rewriting/redirecting modules --mod_alias and mod_rewrite in this case-- is not a very "portable" solution. This is because on any given server, all mod_alias directives will be processed before any mod_rewrite directives or vice-versa, depending on the server configuration. So a mixed-module solution may work properly on one host but not on another, since the execution order of the two modules' directives may be reversed.

In other words, the order in which you place directives for different modules into your configuration code does not make any difference to their 'execution' order -- Each Apache module in turn will execute, handling only the directives that it recognizes in your config files. The module execution order is determined by the reverse LoadModule order on Apache 1.x, and by an internal priority scheme on Apache 2.x.

As a result, I recommend using mod_rewrite exclusively for both external redirects and internal rewrites if any internal rewrites (not supported by mod_alias) are required.

Jim