Connecting Tech Pros Worldwide Forums | Help | Site Map

htaccess is redirecting incorrectly.

Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,938
#1: Mar 5 '09
Why is it not working?

I joke. Here's the info:

In the folder C:\host\www\test, I have an .htaccess file. Inside that .htaccess file is the following:
Expand|Select|Wrap|Line Numbers
  1. RewriteEngine On
  2. RewriteRule ^test1.php$ /test2.php [R]
  3.  
If I then go to the url htxp://localhost/test/test1.php, I am redirected to htxp://localhost/test2.php - I thought that this would redirect me to htxp://localhost/test/test2.php? Clearly not. If I removed the forward slash before the 'test2.php', I am redirected to htxp://localhost/C:/host/www/l/test2.php

I am running EasyPHP 3.

Here's the httpd.conf info that I think relates to this problem:
Expand|Select|Wrap|Line Numbers
  1. #
  2. # DocumentRoot: The directory out of which you will serve your
  3. # documents. By default, all requests are taken from this directory, but
  4. # symbolic links and aliases may be used to point to other locations.
  5. #
  6. DocumentRoot "${path}/www"
  7.  
  8. #
  9. # Each directory to which Apache has access can be configured with respect
  10. # to which services and features are allowed and/or disabled in that
  11. # directory (and its subdirectories). 
  12. #
  13. # First, we configure the "default" to be a very restrictive set of 
  14. # features.  
  15. #
  16. <Directory />
  17.     Options FollowSymLinks
  18.     AllowOverride none
  19.     Order allow,deny
  20.     Deny from all
  21. </Directory>
  22.  
  23. #
  24. # Note that from this point forward you must specifically allow
  25. # particular features to be enabled - so if something's not working as
  26. # you might expect, make sure that you have specifically enabled it
  27. # below.
  28. #
  29.  
  30. #
  31. # This should be changed to whatever you set DocumentRoot to.
  32. #
  33. <Directory "${path}/www">
  34.     #
  35.     # Possible values for the Options directive are "None", "All",
  36.     # or any combination of:
  37.     #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
  38.     #
  39.     # Note that "MultiViews" must be named *explicitly* --- "Options All"
  40.     # doesn't give it to you.
  41.     #
  42.     # The Options directive is both complicated and important.  Please see
  43.     # http://httpd.apache.org/docs/2.2/mod/core.html#options
  44.     # for more information.
  45.     #
  46.     Options Indexes FollowSymLinks
  47.  
  48.     #
  49.     # AllowOverride controls what directives may be placed in .htaccess files.
  50.     # It can be "All", "None", or any combination of the keywords:
  51.     #   Options FileInfo AuthConfig Limit
  52.     #
  53.     AllowOverride All
  54.  
  55.     #
  56.     # Controls who can get stuff from this server.
  57.     #
  58.     Order allow,deny
  59.     Allow from all
  60.  
  61. </Directory>

Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Mar 5 '09

re: htaccess is redirecting incorrectly.


And what happens if you put
Expand|Select|Wrap|Line Numbers
  1. RewriteRule ^test1.php$ /test/test2.php [R]
?
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,938
#3: Mar 5 '09

re: htaccess is redirecting incorrectly.


Ah, yes. That works. I just thought that it would redirect to the same directory the htaccess file was in? I guess not.

Thanks, r0.
Reply