Jump to content

Problem with mod_rewrite (?) on Apache


jakubfox

Recommended Posts

Hi, I have a problem with Apache/PHP configuration:

 

PHP scripts doesn't work when there is a slash after script name, ie.:

 

localhost/test.php/

localhost/test.php/foo

Gives:

Not Found
The requested URL /test.php/costam was not found on this server.

 

- .htaccess seems to work, I've tested that using this simple rewrite rule:

RewriteEngine on
RewriteRule ^alice.html$ bob.html

 

When there is no slash directly after the script name, everything seems to work fine:

 

localhost/test.php

localhost/test.php?boo=foo

localhost/test.php?boo=foo/boofoo

localhost/test.php?boo=foo/boofoo/

localhost/test.php?/boo/

 

/etc/apache2/apache2.conf:

LockFile ${APACHE_LOCK_DIR}/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>
<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>
<IfModule mpm_event_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy all
</Files>
DefaultType text/plain
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
Include mods-enabled/*.load
Include mods-enabled/*.conf
Include httpd.conf
Include /etc/phpmyadmin/apache.conf
Include ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
Include conf.d/
Include sites-enabled/

 

/etc/apache2/httpd.conf:

ServerName localhost

 

/etc/apache2/sites-available/default:

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /home/john/www
<Directory />
	Options FollowSymLinks
	AllowOverride All
</Directory>
<Directory /home/john/www/>
	Options Indexes FollowSymLinks MultiViews
	AllowOverride All
	Order allow,deny
	allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
	AllowOverride All
	Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
	Order allow,deny
	Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>

 

Phpmyadmin works fine but it has no slashes after script name, only parameters.

 

I'll apreciate any help with that.

Link to comment
Share on other sites

I am testing my two projects: one is based on Symfony framework, and it has default htaccess, that looks like this:

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On
  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

 

And Symfony has also it's own routing mechanism but it always worked without any additional tweaks on any server untill now.

The second project has not any htaccess file, I'm just using urls like project/index.php/module/param1/param2 and than I read them from $_SERVER variable in PHP, I don't event have htaccess file and both projects don't work in the same way (becouse there is slash after script name).

 

PhpMyAdmin works fine and it's urls have only ?key=value - like parameters after script name. Also homepage of my Symfony project works fine and it cease to work only when I click anything and url get something more after the slash. So that is why I think that slash is the case but I have no idea what parameter in Apache (PHP maybe?) can be responsible for that.

 

I agree that it shouldn't happen - it's the first time I have this problem and I did a lot of Apache installations before.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.