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
“/<apps_path>” to “/index.php/<apps_path>”.

Any help really appreciated…

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

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

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

Options FollowSymLinks
AllowOverride All

And create my own .htaccess to rewrite the url…

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]

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

Bump?

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

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

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 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 allow from all 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

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

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

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]

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…

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…

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

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

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

-Eric

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

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

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?

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

Distributor ID: Ubuntu Description: Ubuntu 11.10 Release: 11.10 Codename: oneiric