You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by T F <th...@gmail.com> on 2005/12/11 09:28:59 UTC

[users@httpd] detail for a rewrite

My hosting service has my second domain name aliased to my single account.

For example, www.domain.net is aliased to www.domain.com

If a user points their browser to www.domain.com, then they are served
www.domain.com/index.html

If the they point to www.domain.net, then they are served
www.domain.net/o/index.html

In my .htaccess file, the following accomplishes this (but there is a
glitch)

RewriteEngine on
RewriteCond %{HTTP_HOST}   ^www\.domain\.net [NC]
RewriteRule ^$   http://www.domain.net/o/index.html   [R]

If the user points to http://www.domain.net/o/ (with a trailing slash), then
everything is fine.

But if they omit the trailing slash, then the url becomes (note the .com)
http://www.domain.com/o/

I'd like for the url to remain .net.

In fact, i'd like to devise a general solution, such that whenever any
document in the the /o tree is requested, then the url will be rewritten to
the .net.  For example if the user pointed http://www.domain.com/o/file.html,
then it would be rewritten to http://www.domain.net/o/file.html

I've tried a number rewrite conditions and rules, and have consulted
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Any help would be greatly appreciated.

Thanks in advance,
Mike

Re: [users@httpd] Apache2 with Php5

Posted by Imrani <pr...@yahoo.com>.
Thanks Rich,
   
  It worked like a charm.

  - Imrani
   
  
Rich Bowen <rb...@rcbowen.com> wrote:
  Imrani wrote:
> 
> Hi,
> 
> I have installed Apache2 with PHP5 support on FreeBSD 6.0 using ports 
> collection. The installation process seemed to have gone fine but for 
> some reason apache is not able to process the PHP files. It displayes 
> all the code on the browser without processing. Does anyone know why 
> this may be happening?


> --> AddType application/x-httpd-php .php
> --> AddType text/html .shtml .php

That second line overrides the first one.
What you want instead is:

AddHandler application/x-httpd-php .php

-- 
Rich Bowen
rbowen@rcbowen.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See 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

  


			
---------------------------------
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping 

Re: [users@httpd] Apache2 with Php5

Posted by Rich Bowen <rb...@rcbowen.com>.
Imrani wrote:
> 
> Hi,
>  
> I have installed Apache2 with PHP5 support on FreeBSD 6.0 using ports 
> collection. The installation process seemed to have gone fine but for 
> some reason apache is not able to process the PHP files. It displayes 
> all the code on the browser without processing. Does anyone know why 
> this may be happening?


> --> AddType application/x-httpd-php .php
> --> AddType text/html .shtml .php

That second line overrides the first one.
What you want instead is:

AddHandler application/x-httpd-php .php

-- 
Rich Bowen
rbowen@rcbowen.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


[users@httpd] Apache2 with Php5

Posted by Imrani <pr...@yahoo.com>.
  Hi,
   
  I have installed Apache2 with PHP5 support on FreeBSD 6.0 using ports collection. The installation process seemed to have gone fine but for some reason apache is not able to process the PHP files. It displayes all the code on the browser without processing. Does anyone know why this may be happening?
   
  More info is as follows:
   
  1. Noticed that there is php5 module in apache's httpd.conf. Does this prove that apache is configured with php?
   --> LoadModule php5_module        libexec/apache2/libphp5.so

  2. Added/Edited following lines in httpd.conf
  --> DirectoryIndex index.html index.html.var index.php
--> AddType application/x-httpd-php .php
  --> AddType text/html .shtml .php

  3. Saved and restarted apache, but situation is still same.
   
  4. I can execute the php file from command line:
  --> #localhost> php test.php
  this file use mysql_connect and mysql_close functions and executes pretty fine. But when I try to view in the browser, it displays just all that text that is NON-HTML. 
   
  5. file test.php has ownner group as www which is same user that is running apache and file permissions are 644 (rw-r--r--)
   
  Hope this gives enough info. Please let me know if I need to do more.
   
  Thank you,


			
---------------------------------
Yahoo! Shopping
 Find Great Deals on Holiday Gifts at Yahoo! Shopping 

Re: [users@httpd] detail for a rewrite

Posted by T F <th...@gmail.com>.
> >  In fact, i'd like to devise a general solution, such that whenever any
> > document in the the /o tree is requested, then the url will be rewritten to
> > the .net.  For example if the user pointed
> > http://www.domain.com/o/file.html, then it would be
> > rewritten to http://www.domain.net/o/file.html
>
> In the o/.htaccess:
>  RewriteEngine on
>  RewriteCond %{HTTP_HOST}   !^www\.domain\.net$ [NC]
>  RewriteRule (.*)   http://www.domain.net/o/$1  [R]
> (or something like that -- untested).
>
> Joshua.

RewriteCond %{HTTP_HOST}     !^www\.domain\.net [NC]
RewriteCond %{REQUEST_URI}   ^/o/.*
RewriteRule (.*)  /file.not.found.html     [R]

Works finally.  Changed the game plan a little too.

Any .com request for resource in the o directory is now redirected to
a message file.

But this works too:

RewriteRule (.*)  http://www.domain.net/o/$1    [R]

thanks!

Mike

---------------------------------------------------------------------
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] detail for a rewrite

Posted by Joshua Slive <js...@gmail.com>.
On 12/11/05, T F <th...@gmail.com> wrote:

>  In my .htaccess file, the following accomplishes this (but there is a
> glitch)
>
>  RewriteEngine on
>  RewriteCond %{HTTP_HOST}   ^www\.domain\.net [NC]
>  RewriteRule ^$   http://www.domain.net/o/index.html   [R]
>
>  If the user points to http://www.domain.net/o/ (with a trailing slash),
> then everything is fine.
>
>  But if they omit the trailing slash, then the url becomes (note the .com)
> http://www.domain.com/o/

Fixing the UseCanonicalName setting could probably fix that, but it
sounds like you can't access httpd.conf.

>
>  I'd like for the url to remain .net.
>
>  In fact, i'd like to devise a general solution, such that whenever any
> document in the the /o tree is requested, then the url will be rewritten to
> the .net.  For example if the user pointed
> http://www.domain.com/o/file.html, then it would be
> rewritten to http://www.domain.net/o/file.html

In the o/.htaccess:
 RewriteEngine on
 RewriteCond %{HTTP_HOST}   !^www\.domain\.net$ [NC]
 RewriteRule (.*)   http://www.domain.net/o/$1  [R]
(or something like that -- untested).

Joshua.

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