mod_rewrite and location
I use mod_rewrite and in the root of the website I have this in the
..htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [qsappend,last]
</IfModule>
My index.php is simple:
<?php echo "hello"; ?>
My URLs are something like this:
http://localhost/program1/info
http://localhost/program2/info
Now I want to restrict the access to /program2 to certain IP.
I've tried:
<Location />
Order deny,allow
Deny from all
</Location>
<Location /program1>
Order deny,allow
Allow from all
</Location>
<Location /program2>
Order deny,allow
Allow from 127.0.0.1
</Location>
But it doesn't work
If I try to load http://localhost/program2 I get:
"You don't have permission to access /index.php on this server."
So it had something to do with mod_rewrite
Help
------------------------------------------------------------ ---------
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 [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
Re: mod_rewrite and location
--001636c925e44f20000482ed548a
Content-Type: text/plain; charset=ISO-8859-1
Your RewriteRule is wrong redirects everything to index.php in the root
directory where you dont have access
On Mar 29, 2010 8:24 PM, "Henrik Gemal" <hege [at] mail.dk> wrote:
I use mod_rewrite and in the root of the website I have this in the
..htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [qsappend,last]
</IfModule>
My index.php is simple:
<?php echo "hello"; ?>
My URLs are something like this:
http://localhost/program1/info
http://localhost/program2/info
Now I want to restrict the access to /program2 to certain IP.
I've tried:
<Location />
Order deny,allow
Deny from all
</Location>
<Location /program1>
Order deny,allow
Allow from all
</Location>
<Location /program2>
Order deny,allow
Allow from 127.0.0.1
</Location>
But it doesn't work
If I try to load http://localhost/program2 I get:
"You don't have permission to access /index.php on this server."
So it had something to do with mod_rewrite
Help
------------------------------------------------------------ ---------
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 [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org
--001636c925e44f20000482ed548a
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<p>Your RewriteRule is wrong redirects everything to index.php in the root =
directory where you dont have access<br>
</p>
<p><blockquote type=3D"cite">On Mar 29, 2010 8:24 PM, "Henrik Gemal&qu=
ot; <<a href=3D"mailto:hege [at] mail.dk">hege [at] mail.dk</a>> wrote:<br><br>=
=A0I use mod_rewrite and in the root of the website I have this in the .hta=
ccess file:<br>
<br>
<IfModule mod_rewrite.c><br>
=A0 =A0RewriteEngine On<br>
=A0 =A0RewriteCond %{REQUEST_FILENAME} !-d<br>
=A0 =A0RewriteCond %{REQUEST_FILENAME} !-f<br>
=A0 =A0RewriteRule ^(.*)$ index.php?url=3D$1 [qsappend,last]<br>
</IfModule><br>
<br>
My index.php is simple:<br>
<?php echo "hello"; ?><br>
<br>
My URLs are something like this:<br>
<a href=3D"http://localhost/program1/info" target=3D"_blank">http://localho=
st/program1/info</a><br>
<a href=3D"http://localhost/program2/info" target=3D"_blank">http://localho=
st/program2/info</a><br>
<br>
Now I want to restrict the access to /program2 to certain IP.<br>
<br>
I've tried:<br>
<Location /><br>
=A0 Order deny,allow<br>
=A0 Deny from all<br>
</Location><br>
<Location /program1><br>
=A0 Order deny,allow<br>
=A0 Allow from all<br>
</Location><br>
<Location /program2><br>
=A0 Order deny,allow<br>
=A0 Allow from 127.0.0.1<br>
</Location><br>
<br>
But it doesn't work<br>
<br>
If I try to load <a href=3D"http://localhost/program2" target=3D"_blank">ht=
tp://localhost/program2</a> I get:<br>
"You don't have permission to access /index.php on this server.&qu=
ot;<br>
<br>
So it had something to do with mod_rewrite<br>
<br>
Help<br>
<br>
------------------------------------------------------------ ---------<br>
The official User-To-User support forum of the Apache HTTP Server Project.<=
br>
See <URL:<a href=3D"http://httpd.apache.org/userslist.html" target=3D"_b=
lank">http://httpd.apache.org/userslist.html</a>> for more info.<br>
To unsubscribe, e-mail: <a href=3D"mailto:users-unsubscribe [at] httpd.apache.or=
g" target=3D"_blank">users-unsubscribe [at] httpd.apache.org</a><br>
=A0" =A0 from the digest: <a href=3D"mailto:users-digest-unsubscribe [at] =
httpd.apache.org" target=3D"_blank">users-digest-unsubscribe [at] httpd.apache.o=
rg</a><br>
For additional commands, e-mail: <a href=3D"mailto:users-help [at] httpd.apache.=
org" target=3D"_blank">users-help [at] httpd.apache.org</a><br>
<br>
</blockquote></p>
--001636c925e44f20000482ed548a--
Re: mod_rewrite and location
--------------050305090405010909050302
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
The problem is that if I do:
<Location />
Order deny,allow
Deny from all
</Location>
<Location /index.php>
Order deny,allow
Allow from all
</Location>
<Location /program2>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Location>
then calling http://localhost/index.php/program2 would access program2
when he shouldn't
On 29-03-2010 11:42, Igor Cicimov wrote:
>
> Your RewriteRule is wrong redirects everything to index.php in the
> root directory where you dont have access
>
>> On Mar 29, 2010 8:24 PM, "Henrik Gemal" <hege [at] mail.dk
>> <mailto:hege [at] mail.dk>> wrote:
>>
>> I use mod_rewrite and in the root of the website I have this in the
>> .htaccess file:
>>
>> <IfModule mod_rewrite.c>
>> RewriteEngine On
>> RewriteCond %{REQUEST_FILENAME} !-d
>> RewriteCond %{REQUEST_FILENAME} !-f
>> RewriteRule ^(.*)$ index.php?url=$1 [qsappend,last]
>> </IfModule>
>>
>> My index.php is simple:
>> <?php echo "hello"; ?>
>>
>> My URLs are something like this:
>> http://localhost/program1/info
>> http://localhost/program2/info
>>
>> Now I want to restrict the access to /program2 to certain IP.
>>
>> I've tried:
>> <Location />
>> Order deny,allow
>> Deny from all
>> </Location>
>> <Location /program1>
>> Order deny,allow
>> Allow from all
>> </Location>
>> <Location /program2>
>> Order deny,allow
>> Allow from 127.0.0.1
>> </Location>
>>
>> But it doesn't work
>>
>> If I try to load http://localhost/program2 I get:
>> "You don't have permission to access /index.php on this server."
>>
>> So it had something to do with mod_rewrite
>>
>> Help
>>
>> ------------------------------------------------------------ ---------
>> 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 [at] httpd.apache.org
>> <mailto:users-unsubscribe [at] httpd.apache.org>
>> " from the digest: users-digest-unsubscribe [at] httpd.apache.org
>> <mailto:users-digest-unsubscribe [at] httpd.apache.org>
>> For additional commands, e-mail: users-help [at] httpd.apache.org
>> <mailto:users-help [at] httpd.apache.org>
>>
--------------050305090405010909050302
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
The problem is that if I do:<br>
<br>
<Location /><br>
Order deny,allow<br>
Deny from all<br>
</Location><br>
<Location /index.php><br>
Order deny,allow<br>
Allow from all<br>
</Location><br>
<Location /program2><br>
Order deny,allow<br>
Deny from all<br>
Allow from 127.0.0.1<br>
</Location><br>
<br>
then calling <a class="moz-txt-link-freetext" href="http://localhost/index.php/program2">http://localhost/index.php/program2</a> would access
program2 when he shouldn't<br>
<br>
On 29-03-2010 11:42, Igor Cicimov wrote:
<blockquote
cite="mid:f89deef01003290242q12cfe70fl1287438e6e3b9e58 [at] mail. gmail.com"
type="cite">
<p>Your RewriteRule is wrong redirects everything to index.php in
the root directory where you dont have access<br>
</p>
<blockquote type="cite">On Mar 29, 2010 8:24 PM, "Henrik Gemal"
<<a moz-do-not-send="true" href="mailto:hege [at] mail.dk">hege [at] mail.dk</a>>
wrote:<br>
<br>
I use mod_rewrite and in the root of the website I have this in
the .htaccess file:<br>
<br>
<IfModule mod_rewrite.c><br>
RewriteEngine On<br>
RewriteCond %{REQUEST_FILENAME} !-d<br>
RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteRule ^(.*)$ index.php?url=$1 [qsappend,last]<br>
</IfModule><br>
<br>
My index.php is simple:<br>
<?php echo "hello"; ?><br>
<br>
My URLs are something like this:<br>
<a moz-do-not-send="true" href="http://localhost/program1/info"
target="_blank">http://localhost/program1/info</a><br>
<a moz-do-not-send="true" href="http://localhost/program2/info"
target="_blank">http://localhost/program2/info</a><br>
<br>
Now I want to restrict the access to /program2 to certain IP.<br>
<br>
I've tried:<br>
<Location /><br>
Order deny,allow<br>
Deny from all<br>
</Location><br>
<Location /program1><br>
Order deny,allow<br>
Allow from all<br>
</Location><br>
<Location /program2><br>
Order deny,allow<br>
Allow from 127.0.0.1<br>
</Location><br>
<br>
But it doesn't work<br>
<br>
If I try to load <a moz-do-not-send="true"
href="http://localhost/program2" target="_blank">http://localhost/program2</a>
I get:<br>
"You don't have permission to access /index.php on this server."<br>
<br>
So it had something to do with mod_rewrite<br>
<br>
Help<br>
<br>
------------------------------------------------------------ ---------<br>
The official User-To-User support forum of the Apache HTTP
Server Project.<br>
See <URL:<a moz-do-not-send="true"
href="http://httpd.apache.org/userslist.html" target="_blank">http://httpd.apache.org/userslist.html</a>>
for more info.<br>
To unsubscribe, e-mail: <a moz-do-not-send="true"
href="mailto:users-unsubscribe [at] httpd.apache.org"
target="_blank">users-unsubscribe [at] httpd.apache.org</a><br>
" from the digest: <a moz-do-not-send="true"
href="mailto:users-digest-unsubscribe [at] httpd.apache.org"
target="_blank">users-digest-unsubscribe [at] httpd.apache.org</a><br>
For additional commands, e-mail: <a moz-do-not-send="true"
href="mailto:users-help [at] httpd.apache.org" target="_blank">users-help [at] httpd.apache.org</a><br>
<br>
</blockquote>
</blockquote>
</body>
</html>
--------------050305090405010909050302--
Re: mod_rewrite and location
10/03/29 Henrik Gemal
> I use mod_rewrite and in the root of the website I have this
> in the .htaccess file:
Hi,
mixing Location with .htaccess sounds wrong to me, as Location
should be processed before URL-to-file mapping, but .htaccess can
only be accessed after URL-to-file mapping.
Be sure to read about the rewrite base directive here:
http://httpd.apache.org/docs/2.2/en/mod/mod_rewrite.html
and even if you don't understand all of the details, you should
read this:
http://httpd.apache.org/docs/2.2/en/rewrite/rewrite_tech.htm l
Then, define a RewriteLog (see mod_rewrite documentation) and set
a RewriteLogLevel of 3 or 4 and watch carefully what's going on
inside of mod_rewrite.
This really puts you into the position of understanding the
details instead of just providing you a predefined config which
works for your special case.
But, if you have further questions, feel free to ask.
Regards,
Edgar
------------------------------------------------------------ ---------
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 [at] httpd.apache.org
" from the digest: users-digest-unsubscribe [at] httpd.apache.org
For additional commands, e-mail: users-help [at] httpd.apache.org