You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Alain Roger <ra...@gmail.com> on 2008/09/15 14:06:38 UTC

[users@httpd] PHP and .htaccess

Hi,

if i make a compilation of all information i have between PHP and apache
RewriteRule i have an issue.

let's take an example.

1. user types in his favorite browser www.website.com
2. www.website.com/index.php redirects user to
www.website.com/en/welcome/(index.php within /welcome) thanks the
following command: header("Location:
http://www.website.com/en/welcome/");
3. however, as /en/welcome does not exist, apache sends an error message:
The requested URL /se_internet/en/welcome/ was not found on this server.

even if i have in my .htaccess file:
RewriteRule ^/([A-Za-z0-9-]+)/welcome/$ /welcome/index.php?lang=$1 [NC,L]

4. user should at the end have in his browser address bar
http://www.website.com/en/welcome (knowing that apache would reroute him to
www.website.com/welcome/index.php?lang=en)

so where is the problem ?
is there a problem with RewriteRule when you reroute only virtual folders ?

-- 
Alain
------------------------------------
Windows XP SP3
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008

Re: [users@httpd] PHP and .htaccess

Posted by Alain Roger <ra...@gmail.com>.
>
> Alain, let me insist.
> Did you configure a RewriteLog and RewriteLogLevel, and did you look at the
> resulting lines, to see what happens ?
> It may save you a lot of wondering.
>
> Apart from that, from the above I guess that somewhere you have a config
> line like
> DirectoryIndex index.php
> and another one allowing directory indexes, in each of the directories to
> which you may be redirected. Yes ?
> If you did not allow directory indexes in your target directories, then
> that might explain why Apache is not looking for "index.php" and says "not
> found".
>
> no problem to insist.
yes i did it as you suggested.

so here is what i have in my httpd.conf file:

<IfModule dir_module>
>     DirectoryIndex index.html index.php
> </IfModule>
>
> Alias /se_internet/ "L:/Webserver/se/internet/"
> <Directory "L:/Webserver/se/internet/">
>     Options Indexes FollowSymLinks
>     AllowOverride All
>     Order allow,deny
>     Allow from all
> </Directory>


>
# allow to track all RewriteRules from .htaccess file
> RewriteEngine on
> RewriteLog logs/rewrite.log
> RewriteLogLevel 9
>

www.website.com is replaced by my local ip address from servername.

here is what i have in the rewrite.log file
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fad060/initial] (2) init rewrite engine with
requested uri /se_internet/
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fad060/initial] (1) pass through /se_internet/
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fad060/initial] (3) [perdir
L:/Webserver/se/internet/] strip per-dir prefix: L:/Webserver/se/internet/
->
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fad060/initial] (3) [perdir
L:/Webserver/se/internet/] applying pattern '^/([A-Za-z0-9-]+)/welcome/$' to
uri ''
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fad060/initial] (1) [perdir
L:/Webserver/se/internet/] pass through L:/Webserver/se/internet/
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fbe090/subreq] (2) init rewrite engine with
requested uri /se_internet/index.html
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fbe090/subreq] (1) pass through
/se_internet/index.html
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fbe090/subreq] (3) [perdir
L:/Webserver/se/internet/] strip per-dir prefix:
L:/Webserver/se/internet/index.html -> index.html
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fbe090/subreq] (3) [perdir
L:/Webserver/se/internet/] applying pattern '^/([A-Za-z0-9-]+)/welcome/$' to
uri 'index.html'
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fbe090/subreq] (1) [perdir
L:/Webserver/se/internet/] pass through L:/Webserver/se/internet/index.html
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fbe090/subreq] (2) init rewrite engine with
requested uri /se_internet/index.php
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fbe090/subreq] (1) pass through
/se_internet/index.php
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fbe090/subreq] (3) [perdir
L:/Webserver/se/internet/] strip per-dir prefix:
L:/Webserver/se/internet/index.php -> index.php
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fbe090/subreq] (3) [perdir
L:/Webserver/se/internet/] applying pattern '^/([A-Za-z0-9-]+)/welcome/$' to
uri 'index.php'
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fbe090/subreq] (1) [perdir
L:/Webserver/se/internet/] pass through L:/Webserver/se/internet/index.php
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fb5078/initial] (2) init rewrite engine with
requested uri /se_internet/en/welcome/
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fb5078/initial] (1) pass through
/se_internet/en/welcome/
my_IP_Addres - - [15/Sep/2008:14:42:50 +0200]
[my_IP_Addres/sid#6b5148][rid#fb5078/initial] (1) [perdir
L:/Webserver/se/internet/en/] pass through
L:/Webserver/se/internet/en/welcome
my_IP_Addres - - [15/Sep/2008:14:42:53 +0200]
[my_IP_Addres/sid#6b5148][rid#fad060/initial] (2) init rewrite engine with
requested uri /favicon.ico
my_IP_Addres - - [15/Sep/2008:14:42:53 +0200]
[my_IP_Addres/sid#6b5148][rid#fad060/initial] (1) pass through /favicon.ico

is it better ?
:-)

Re: [users@httpd] PHP and .htaccess

Posted by André Warnier <aw...@ice-sa.com>.
Alain Roger wrote:
> Hi,
> 
> if i make a compilation of all information i have between PHP and apache
> RewriteRule i have an issue.
> 
> let's take an example.
> 
> 1. user types in his favorite browser www.website.com
> 2. www.website.com/index.php redirects user to
> www.website.com/en/welcome/(index.php within /welcome) thanks the
> following command: header("Location:
> http://www.website.com/en/welcome/");
> 3. however, as /en/welcome does not exist, apache sends an error message:
> The requested URL /se_internet/en/welcome/ was not found on this server.
> 
> even if i have in my .htaccess file:
> RewriteRule ^/([A-Za-z0-9-]+)/welcome/$ /welcome/index.php?lang=$1 [NC,L]
> 
> 4. user should at the end have in his browser address bar
> http://www.website.com/en/welcome (knowing that apache would reroute him to
> www.website.com/welcome/index.php?lang=en)
> 
> so where is the problem ?
> is there a problem with RewriteRule when you reroute only virtual folders ?
> 
Alain, let me insist.
Did you configure a RewriteLog and RewriteLogLevel, and did you look at 
the resulting lines, to see what happens ?
It may save you a lot of wondering.

Apart from that, from the above I guess that somewhere you have a config 
line like
DirectoryIndex index.php
and another one allowing directory indexes, in each of the directories 
to which you may be redirected. Yes ?
If you did not allow directory indexes in your target directories, then 
that might explain why Apache is not looking for "index.php" and says 
"not found".


---------------------------------------------------------------------
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] PHP and .htaccess

Posted by Eric Covener <co...@gmail.com>.
On Mon, Sep 15, 2008 at 8:06 AM, Alain Roger <ra...@gmail.com> wrote:

> even if i have in my .htaccess file:
> RewriteRule ^/([A-Za-z0-9-]+)/welcome/$ /welcome/index.php?lang=$1 [NC,L]

No leading slash is present in what you match against in .htaccess
(it's stripped off along with the RewriteBase)

--
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