[PHP] Re: mod_rewrite from .htaccess

2005-04-13 Thread Dasmeet Singh
Matthew Weier O'Phinney wrote:
* Amir Mohammad Saied <[EMAIL PROTECTED]>:
I want to use mod_rewrite patterns, but i have not access to the 
httpd.conf so i think i should use .htaccess, but the patterns don't 
work properly there, have my admin should set any settings in the 
httpd.conf?

I use mod_rewrite from .htaccess all the time; just make sure that you
have the 'RewriteEngine on' directive in your .htaccess file before your
rewrite rules. 

It's entirely possible, however, that the server admin has denied
permission for that action in the global httpd.conf, though. If you
simply cannot get rules to work -- rules that you know work on another
machine, for instance, that would be the next step to try.
This should help you :)
http://www.yourhtmlsource.com/sitemanagement/urlrewriting.html
http://www.webmasterworld.com/forum92/82.htm
Regards,
Dasmeet
http://hostwindow.info
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: mod_rewrite from .htaccess

2005-04-12 Thread Matthew Weier O'Phinney
* Amir Mohammad Saied <[EMAIL PROTECTED]>:
> I want to use mod_rewrite patterns, but i have not access to the 
> httpd.conf so i think i should use .htaccess, but the patterns don't 
> work properly there, have my admin should set any settings in the 
> httpd.conf?

I use mod_rewrite from .htaccess all the time; just make sure that you
have the 'RewriteEngine on' directive in your .htaccess file before your
rewrite rules. 

It's entirely possible, however, that the server admin has denied
permission for that action in the global httpd.conf, though. If you
simply cannot get rules to work -- rules that you know work on another
machine, for instance, that would be the next step to try.

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: mod_rewrite and getting url variables

2005-04-12 Thread Matthew Weier O'Phinney
* Ospinto <[EMAIL PROTECTED]>:
> I used mod_rewrite to change http://www.mysite.com/page/1 to
> http://www.mysite.com/page.php?id=1 to enable a search friendly url.
> Everything works fine, except that when I try to get the URL variable ($id)
> by using $_GET, it doesn't return anything. With
> http://www.mysite.com/page.php?id=1 it gets $id just fine. I thought the
> mod_rewrite would keep the url variables??? If not, I know the alternative
> would be to get the whole url as a string and change it to an array by using
> the "/" as the delimiter and obtain $id from that. But I'd rather go that
> way if there's no other alternative.
> The .htaccess file has the following commands:
>
> RewriteEngine On
> RewriteRule ^page/([0-9]+)/?$ page.php?id=$1 [L]

Try [PT] instead of [L]. [PT] does a Pass-Through -- i.e., passes it on
to the appropriate handler once the rewrite has been performed. Without
this, the page will not be processed as a CGI.

-- 
Matthew Weier O'Phinney   | WEBSITES:
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:[EMAIL PROTECTED] | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: mod_rewrite problem

2002-07-18 Thread Sameh Attia

Adrian Murphy wrote:
> 
> Hi,
> the following code redirects www.usersite.mysite.biz  to 
>www.mysite.biz/users/sites/usersite
> 
> the problem is when the 'www' is left out it doesn't work.
> could someone help me to fix this?
> many thanks
> 
> 
> 
> 
> RewriteEngine on
> RewriteCond   %{HTTP_HOST} ^www\.[^.]+\.mysite\.biz$
> RewriteRule   ^(.+)%{HTTP_HOST}$1  [C]
> RewriteRule   ^www\.([^.]+)\.mysite\.biz(.*) http://www.mysite.biz/users/sites/$1
> RewriteCond   %{HTTP_HOST} ^www\.[^.]+\.mysite\.ie$
> RewriteRule   ^(.+)%{HTTP_HOST}$1  [C]
> RewriteRule   ^www\.([^.]+)\.mysite\.ie(.*) http://www.mysite.biz/users/sites/$1
> 
> 
> adrian.
> 

Hi,
According to your rewrites the following line makes no sense
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
so remove itthis does not solve your problem
also modify your rewrite conds to read ^(www\.)?[^.]+mysite\.biz$
This also applies to www.username.mysite.ie
Regards
-- 
Sameh Attia
Senior System Engineer
T.E. Data
--
__  __  _
_ _/ /_/ /_(_)___ _
   / ___/ __ `/ __/ __/ / __ `/
  (__  ) /_/ / /_/ /_/ / /_/ /
//\__,_/\__/\__/_/\__,_/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: mod_rewrite problem

2002-07-18 Thread CC Zona

In article <003d01c22e58$dcb45240$6601a8c0@yourwrjlo8t8dt>,
 [EMAIL PROTECTED] (Adrian Murphy) wrote:

> the following code redirects www.usersite.mysite.biz  to 
> www.mysite.biz/users/sites/usersite
> 
> the problem is when the 'www' is left out it doesn't work.

> RewriteEngine on
> RewriteCond   %{HTTP HOST} ^www\.[^.]+\.mysite\.biz$
> RewriteRule   ^(.+)%{HTTP HOST}$1  [C]
> RewriteRule   ^www\.([^.]+)\.mysite\.biz(.*) 
> http://www.mysite.biz/users/sites/$1
> RewriteCond   %{HTTP HOST} ^www\.[^.]+\.mysite\.ie$
> RewriteRule   ^(.+)%{HTTP HOST}$1  [C]
> RewriteRule   ^www\.([^.]+)\.mysite\.ie(.*) 
> http://www.mysite.biz/users/sites/$1

Change each of those instances of "^www\." to "^(www\.)?"

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: mod_rewrite

2002-04-22 Thread Philip Hallstrom

You could also do something like this:

Configure Apache so that *every* request on a virtual
host would be handled by a single PHP script.


 ServerName myserver.mydomain.org
 DocumentRoot /usr/local/www/myserver
 Action php-parse /path-to/script.php

 Action php-parse /path-to/script.php
 SetHandler php-parse

 
   SetHandler "application/x-httpd-php"
 


Every request (whether the file exists or not) is handled by
/path-to/script.php.

Note that this means that gifs/jpgs also get run through this...


On Wed, 17 Apr 2002, [ rswfire ] wrote:

> I could really use your help with this.  The examples I have received from
> everyone thus far have not worked, including the last one that you posted.
> This is the situation:
>
> I have multiple domains, each with multiple subdomains, all of which
> automatically point to the root of my web environment.  I have only one file
> that does all of the work for all of these websites/webpages, and that is
> the index.php file in the root.  This file is smart enough to parse the url
> being accessed and create an appropriate page based on a very complex set of
> rules.
>
> Originally, I was using the ErrorDocument 404 to make it access the
> index.php file, but this has some inherent flaws.  The biggest problem was
> that forms that were being posted to a page that doesn't really exist never
> maintained the posted variables (due to the 404 redirect.)  Another
> limitation was that it just created a bunch of unnecessary error messages in
> my error log since there are no "real pages" on my network, even though it
> pretends there is.
>
> So, I need to use mod_rewrite.  That is apparent now.  The problem is I know
> nothing about creating regular expressions.  I simply need it to rewrite the
> url for any file that does not exist (it should not try to do so for a file
> that really does exist, say an image file) and it needs to have the
> following rule:
>
> A*.B*.C*/D*.E*
>
> Where A is a subdomain; B is the domain name; C is the top level domain; D/E
> are a file or directory.
>
> Some examples would be:
>
> http://www.swifte.net/
> http://www.cao.swifte.net/petition-sign.html
> http://hsdnetwork.swifte.net/technicians.html
> http://www.hsdnetwork.swifte.net/technicians.html
> http://www.caofund.org/
> http://www.hsdnetwork.com/
>
> Can you tell me how to do this?  I would appreciate your help so much!!
>
> -Samuel
>
> _
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: mod_rewrite

2002-04-18 Thread Maxim Maletsky


forget about using .htaccess for mod_rewrite. It often fails through it.
Use it directly from httpd.conf 


Maxim Maletsky 

Founder, Chief Developer
PHPBeginner.com (Where PHP Begins) 

www.PHPBeginner.com
[EMAIL PROTECTED] 

 

 

[ rswfire ] writes: 

> .htaccess  (returns 500 misconfiguration error message)
> { 
> 
> RewriteEngine  on
> RewriteBase/
> RewriteRule* index.php 
> 
> } 
> 
> http://swifte.net/phpinfo.php 
> 
> (i did not use braces in the .htaccess file) 
> 
> _
> Join the world’s largest e-mail service with MSN Hotmail. 
> http://www.hotmail.com 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php 
> 
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: mod_rewrite

2002-04-18 Thread Maxim Maletsky


Seriousely speaking, I don't think I can create you a working example here 
because your case might be a whole different one, so you'd better read the 
docs to get it right. To just give you an idea, here's what I use on 
PHPBeginner.com: 

# VHosts: 

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} -f
RewriteRule ^(.+) - [L]
RewriteRule ^(.+) /index.php?%{QUERY_STRING}&_PHPB_URL=$1 [L] 


basically in human language it is: 

Line 1: action: start Rewrite Engine
Line 2: condition: if the requested file exists
Line 3: solution: go to the untouched URL (the engine would stop here)
Line 4: alternative: if arrived all the way to this line go to 
"/index.php?query=URL" 


So, in the root we only have one single file (index.php) amd all the 
requests are coming in to it as $_GET['_PHPB_URL'], there we take over the 
game and decide what instances to lunch up from some shared libraries 
outside the root. 

In your case I think it would still similar, except, you could read the 
apache docs better and assign more variables in your regex so you get the 
correct data. Don't be too lazy, soon or later you will need Regular 
Expression again, so thi is a good chance to learn them. :-) 


Cheers, 

Maxim Maletsky
Founder, Chief Developer.
www.PHPBeginner.com 

 


[ rswfire ] writes: 

> I could really use your help with this.  The examples I have received from 
> everyone thus far have not worked, including the last one that you posted. 
> This is the situation: 
> 
> I have multiple domains, each with multiple subdomains, all of which 
> automatically point to the root of my web environment.  I have only one 
> file that does all of the work for all of these websites/webpages, and 
> that is the index.php file in the root.  This file is smart enough to 
> parse the url being accessed and create an appropriate page based on a 
> very complex set of rules. 
> 
> Originally, I was using the ErrorDocument 404 to make it access the 
> index.php file, but this has some inherent flaws.  The biggest problem was 
> that forms that were being posted to a page that doesn't really exist 
> never maintained the posted variables (due to the 404 redirect.)  Another 
> limitation was that it just created a bunch of unnecessary error messages 
> in my error log since there are no "real pages" on my network, even though 
> it pretends there is. 
> 
> So, I need to use mod_rewrite.  That is apparent now.  The problem is I 
> know nothing about creating regular expressions.  I simply need it to 
> rewrite the url for any file that does not exist (it should not try to do 
> so for a file that really does exist, say an image file) and it needs to 
> have the following rule: 
> 
> A*.B*.C*/D*.E* 
> 
> Where A is a subdomain; B is the domain name; C is the top level domain; 
> D/E are a file or directory. 
> 
> Some examples would be: 
> 
> http://www.swifte.net/
> http://www.cao.swifte.net/petition-sign.html
> http://hsdnetwork.swifte.net/technicians.html
> http://www.hsdnetwork.swifte.net/technicians.html
> http://www.caofund.org/
> http://www.hsdnetwork.com/ 
> 
> Can you tell me how to do this?  I would appreciate your help so much!! 
> 
> -Samuel 
> 
> _
> Chat with friends online, try MSN Messenger: http://messenger.msn.com 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php 
> 
 


Maxim Maletsky 

Founder, Chief Developer
PHPBeginner.com (Where PHP Begins) 

www.PHPBeginner.com
[EMAIL PROTECTED] 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: mod_rewrite (the solution)

2002-04-17 Thread CC Zona

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Cc Zona) wrote:

> In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
> wrote:
> 
> > RewriteEngine  on
> > RewriteBase/
> > RewriteRule$.* index.php
> 
> RewriteRule takes a regular expression as its first parameter 
> .
> 
> The "$" regex meta-character is an end-of-line marker.  It has no special 
> meaning at the beginning of a pattern.  If you want a pattern that matches 
> "anything including nothing", use:
> 
> RewriteRule ^.*$ index.php

I shouldn't have copy/pasted, because "index.php" also is wrong in this 
context.  If one is trying to redirect from, say, 
"/dir_that_may_not_exist/" to "index.php", then how is apache supposed to 
serve up "/dir_that_may_not_exist/index.php".  It can't.  So logically the 
2nd parameter has to be "/index.php".  For clarity's sake, using the "L" 
modifier for parameter #3 is also a good idea:

RewriteRule ^.*$ /index.php [L]

Mod_rewrite is a complex beast, so read the docs closely.  And if all you 
really need is to capture/redirect 404s, check out the ErrorDocument 
directive instead.  Simple to use, easy to learn, and none of the 
mod_rewrite overhead.

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: mod_rewrite (the solution)

2002-04-17 Thread CC Zona

In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] 
wrote:

> RewriteEngine  on
> RewriteBase/
> RewriteRule$.* index.php

RewriteRule takes a regular expression as its first parameter 
.

The "$" regex meta-character is an end-of-line marker.  It has no special 
meaning at the beginning of a pattern.  If you want a pattern that matches 
"anything including nothing", use:

RewriteRule ^.*$ index.php

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php