Apache 2.2.3 and mod_rewrite

Discuss practical ways rearrange URLs using mod_rewrite.

Apache 2.2.3 and mod_rewrite

Postby smrtalex » Tue Sep 30, 2008 6:43 pm

I have a server that is running CentOS4 with Apache 2.0.52 that is running fine with the following .htaccess file:

Code: Select all
Options +ExecCGI
AddHandler cgi-script .cgi .pl
 
AuthUserfile /domainname.com/htdocs/dir/.htpasswd
AuthGroupFile /dev/null
AuthName "Private"
AuthType Basic
 
#require valid-user
 
<Files "file.php">
allow from all
satisfy any
</Files>
 
<Files ~ "\.(png)$">
allow from all
satisfy any
</Files>
 
RewriteEngine On
RewriteRule file.pl file.php



The new server I have running RHEL5 with Apache 2.2.3 with the same httpd.conf file as the 2.0.52 will not run the above .htaccess file, but must be modified as below to work (see last line).

Code: Select all
Options +ExecCGI
AddHandler cgi-script .cgi .pl
 
AuthUserfile /domainname.com/htdocs/dir/.htpasswd
AuthGroupFile /dev/null
AuthName "Private"
AuthType Basic
 
#require valid-user
 
<Files "file.php">
allow from all
satisfy any
</Files>
 
<Files ~ "\.(png)$">
allow from all
satisfy any
</Files>
 
RewriteEngine On
#RewriteRule file.pl file.php



As you can see the bottom line needs to be commented out. It seems that is gets caught in a loop! The looping I am referring to gives the following error in the error.log:

Code: Select all
Request exceeded the limit of 10 subrequest nesting levels due to probable confguration error. Use 'LimitInternalRecursion' to increase the limit if necessary.


We have put LimitInternalRecursion to 2000 and the issue still remained. So we removed it.

Here are the all of the loaded httpd modules:

#grep LoadModule /etc/httpd/conf/httpd.conf |grep -v '^#'
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_alias_module modules/mod_authn_alias.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule ldap_module modules/mod_ldap.so
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
LoadModule include_module modules/mod_include.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule info_module modules/mod_info.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule cache_module modules/mod_cache.so
LoadModule suexec_module modules/mod_suexec.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule version_module modules/mod_version.so
LoadModule php4_module /usr/lib/httpd/modules/libphp4.so

We do know that mod_rewrite is working as we testing it using the following directions:
http://www.wallpaperama.com/forums/how- ... d-t40.html

What config in the httpd.conf file can be used to make the .htaccess file work without without having to comment out the 'RewriteRule' line?
smrtalex
 
Posts: 5
Joined: Sun Sep 23, 2007 9:35 am

Postby richardk » Wed Oct 01, 2008 11:14 am

Try a better rule
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^file\.pl$ /file.php [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby smrtalex » Wed Oct 01, 2008 1:23 pm

Without changing the .htaccess or the rule, is there something in the apache config that would make this work? Thanks!
smrtalex
 
Posts: 5
Joined: Sun Sep 23, 2007 9:35 am

Postby richardk » Wed Oct 01, 2008 2:24 pm

No, not as far as i know.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby smrtalex » Wed Oct 01, 2008 2:35 pm

Any thoughts as to why it would work in Apache 2.0.52 but not 2.2.3?
smrtalex
 
Posts: 5
Joined: Sun Sep 23, 2007 9:35 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 25 guests

cron