mod_rewrite enable is not function?

22 posts / 0 new
Last post
#1 Fri, 10/14/2011 - 19:51
khairun

mod_rewrite enable is not function?

Hi,

I tried to install web apps on my server, there was impression from the developer that my apache rewrite module is not function, while I can verify that the module (rewrite) is enable in the webmin. the pat supposed to Actually, all request made to apps, are request made to the "index.php" file. the web_apps trusts the apache rewriting system to transform any "/" to "/index.php/".

Any help really appreciated...

Fri, 10/14/2011 - 19:53
khairun
Actually, all request made to apps, are request made to the "index.php" 
file. web apps trusts the apache rewriting system to transform any 
"/<apps_path>" to "/index.php/<apps_path>". <code>
Fri, 10/14/2011 - 20:00
andreychek

The mod_rewrite module should be available in Apache by default -- and that's something your developer should be able to make use of from a .htaccess file.

Are they getting an error of some kind? If so, what error are they getting?

-Eric

Sat, 10/15/2011 - 01:08
khairun

If I manually force to use url www.domain.com/index.php/apps I managed to get the login screen, after submitting the proper login screen and password It went to www.domain.com/apps and it gave me this error.. The requested URL /login was not found on this server.

According to the developer it should www.domain.com/index.php/apps as they mentioned that all request made to webapps, are request made to the "index.php

**updates I tried to set the the AllowOveyride to All

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All

And create my own .htaccess to rewrite the url..

<IfModule mod_rewrite.c> 
        RewriteEngine On 
        RewriteBase / 
        RewriteCond %{REQUEST_FILENAME} !-f 
        RewriteCond %{REQUEST_FILENAME} !-d 
        RewriteCond %{REQUEST_URI} !^/index.php 
        RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC] 
        RewriteRule (.*) index.php 
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L] 
</IfModule> 

Some other weird sitiuation, instead rewrite the url to index.php, apparently it trying to rewrite the url to "domain.com/cgi-bin/php5.cgi/webapps" Which is what I want is domain.com/index.php/webapps

any suggestion are welcome... Thanks

Sun, 10/16/2011 - 09:28
khairun

Bump?

Sun, 10/16/2011 - 10:21
andreychek

Howdy,

Well, there's nothing in that which tells it to redirect to the URL you're seeing -- that may mean it's the application itself doing that, not mod_rewrite.

Also, note that for mod_rewrite to work, each VirtualHost block in the Apache config that needs to use mod_rewrite needs to have "Allowoverride None" set.

And if you're seeing 500 errors -- you can look in $HOME/logs/error_log to see what the problem is, the details of the error you saw should be listed in there.

-Eric

Sun, 10/16/2011 - 19:17 (Reply to #7)
khairun

on the error log mostly I see..

[Mon Oct 17 08:04:09 2011] [error] [client 110.139.177.53] Premature end of script headers: php5.cgi, referer: http://domain.com/

Then when I tried to force access link http://domain.com/index.php/login

I got the login screen but after I submit my user name and password it's redirect me to... http://domain.com/cgi-bin/php5.cgi/dashboard

And below the logs from apache

[Mon Oct 17 08:07:19 2011] [error] [client 110.139.177.53] Premature end of script headers: php5.cgi, referer: http://domain.com/index.php/login
Sun, 10/16/2011 - 19:35 (Reply to #8)
khairun

Hi Eric,

Can you please give me advice, if there something that I need to changes on this line.. this one was automatically generated by Virtualmin. Thanks a lot...

SuexecUserGroup "#1006" "#1007"
ServerName myapps.domain.com
ServerAlias www.myapps.domain.com
ServerAlias webmail.myapps.domain.com
ServerAlias admin.myapps.domain.com
DocumentRoot /home/domain.com/domains/myapps.domain.com/public_html
ErrorLog /var/log/virtualmin/myapps.domain.com_error_log
CustomLog /var/log/virtualmin/myapps.domain.com_access_log combined
ScriptAlias /cgi-bin/ /home/domain.com/domains/myapps.domain.com/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/domain.com/domains/myapps.domain.com/public_html>
Options -Indexes +IncludesNOEXEC +FollowSymLinks
allow from all
AllowOverride All
Action application/x-httpd-php5 /cgi-bin/php5.cgi
AddType application/x-httpd-php5 .php5
AddType application/x-httpd-php5 .php
</Directory>
<Directory /home/domain.com/domains/myapps.domain.com/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.myapps.domain.com
RewriteRule ^(.*) http://myapps.domain.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.myapps.domain.com
RewriteRule ^(.*) https://myapps.domain.com:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
Sun, 10/16/2011 - 20:31 (Reply to #9)
khairun

Here's some other configuration .htaccess, in case you missed it..

GNU nano 2.2.6              File: .htaccess

  <FilesMatch "pre_.+\.php">
    Order deny,allow
    Deny  from all
  </FilesMatch>
</IfModule>


<IfModule mod_rewrite.c>
  RewriteEngine On

  # uncomment the following line, if you are having trouble
  # getting no_script_name to work
  #RewriteBase /

  # we skip all files with .something
  RewriteCond %{REQUEST_URI} \..+$
  RewriteCond %{REQUEST_URI} !\.html$
  RewriteRule .* - [L]
Sun, 10/16/2011 - 20:07
andreychek

Well, as I mentioned -- I think the issue is with your application, rather than with mod_rewrite (or your Apache config).

Your application is likely using PHP's $_SERVER['SCRIPT_NAME'] variable to determine the URL to use, and that won't work correctly when using the CGI or FCGID PHP execution modes, it needs to determine that information a different way.

If it's an application you're building, the best way to fix it is to change the code to not use $_SERVER['SCRIPT_NAME'] to generate your URL's.

If it's a pre-existing application -- some applications can be corrected by editing your $HOME/etc/php.ini file, and setting "cgi.fix_pathinfo" to "0".

Another way to resolve it may be to go into Server Configuration -> Website Options, and change the PHP Execution Mode to mod_php.

-Eric -Eric

Sun, 10/16/2011 - 20:42 (Reply to #11)
khairun

Hi,

on you remarks.. "Another way to resolve it may be to go into Server Configuration -> Website Options, and change the PHP Execution Mode to mod_php."

I dont think that I have that option on my screen.. Please see attached...

Mon, 10/17/2011 - 04:00
khairun

Hi,

Just find the solution... just need change mode to mod_php. by doing this ..

apt-get install libapache2-mod-php5 --reinstall

Following this thread .. https://www.virtualmin.com/node/15960

So far so good thanks...

Mon, 10/17/2011 - 09:53
andreychek

That's great that you got it working!

Normally, mod_php is configured by default... it's possible that it was disabled along the way though.

-Eric

Mon, 10/17/2011 - 19:46 (Reply to #14)
khairun

Hi Eric,

I would love to have the FCGId as another option, how can I achieve that? If you look on my attachment i dont have the FCGId option either.

Thanks,

Khairun

Mon, 10/17/2011 - 19:51
andreychek

How did you install Virtualmin? Did you use the install.sh script to perform the installation?

-Eric

Mon, 10/17/2011 - 19:55
khairun

Yes, I did, but base on the last experience, it might be disable along the way...

Mon, 10/17/2011 - 20:02
andreychek

Yeah, Virtualmin's install.sh would enable FCGID by default.

So, how to re-enable that depends on how it was disabled, as well as what distribution you're using.

-Eric

Mon, 10/17/2011 - 20:06
khairun

Thanks for your response, how can I determine if it was disable or not? I'm expecting to have a way just to re-install command maybe?

Mon, 10/17/2011 - 21:30
andreychek

How to do all that depends on your distribution... what distribution are you using?

Mon, 10/17/2011 - 21:52
khairun
Distributor ID: Ubuntu
Description:    Ubuntu 11.10
Release:        11.10
Codename:       oneiric
Mon, 10/17/2011 - 22:28
andreychek

Well, note that Ubuntu 11.10 isn't one of the distros supported by Virtualmin, so that may be related to why you're running into some problems.

You can see the supported distros here:

http://www.virtualmin.com/compare.html

However, you can determine if mod_fcgid is installed with this command:

dpkg -l libapache2-mod-fcgid

If it is installed, you can make sure it's enabled with this command:

a2enmod fcgid

After enabling it, you'll need to restart Apache for that to take effect.

-Eric

Mon, 10/17/2011 - 23:27
khairun

I'm running FCGID mode right now... cool.. case is closed... thank you very much Eric....

Topic locked