1

I have downloaded a php web application from the web (OntoWiki). After the installation I've tried it and it works fine on my Ubuntu 10.10, but when I try to install it on CentOS Linux, the only page that works is the home page (index.php). If i try to change the page, the browser sends me a 404 error page (page not found). Instead if i try to change the URL with the "index.php" as prefix it works fine. Example:

  • localhost/app/index.php/directory -> works
  • localhost/app/directory -> doesn't work (404 error)

Why does this happen? On the PC where the program works i have the URL like: host/application but everything works fine.

Is there an Apache Configuration problem?

Thanks in advance

Wolfgang Fahl
  • 15,016
  • 11
  • 93
  • 186
frakorn
  • 109
  • 1
  • 2
  • 5

3 Answers3

2

Check you have mod_rewrite enabled on your CentOS server.

Petah
  • 45,477
  • 28
  • 157
  • 213
2

Active the Apache rewrite module:

a2enmod rewrite

Restart Apache.

vinnylinux
  • 7,050
  • 13
  • 61
  • 127
2

In an application like OntoWiki, all requests are directed through index.php. An .htaccess file accompanies the project including RewriteRule's to map a path like /directory to /index.php/directory.

Apache's mod_rewrite module must be installed and enabled for the host in order for the RewriteRules to be applied. It sounds like you have it disabled on your CentOS box and enabled locally.

white_gecko
  • 4,808
  • 4
  • 55
  • 76
deefour
  • 34,974
  • 7
  • 97
  • 90
  • My WebApp is located at the folder /home//public_html so i should i decomment this part? # # AllowOverride FileInfo AuthConfig Limit All # Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec # # Order allow,deny # Allow from all # # # Order deny,allow # Deny from all # # – frakorn Feb 23 '12 at 09:55
  • `AllowOverride` is set to 'None' by default. Setting it to at least `FileInfo` for that `` may be necessary after `mod_rewrite` is enabled. – deefour Feb 23 '12 at 12:19
  • How can i enable mod_rewrite in centOS? – frakorn Feb 23 '12 at 13:11
  • @vinnylinux's comment tells you how. Google is also your friend "how to enable mod_rewrite in CentOS". – deefour Feb 23 '12 at 14:30
  • Last question (i hope :P ): i've enabled mod_rewrite, and after decommented that part above (in my httpd.conf), now i have an error 404 at the main page (located at host/ontowiki) with index.php not found. But if i type the complete url (http://.../~user/ontowiki/index.php) the page work but still not working the link of this page. Should i change the symbol '*' with my username in the httpd.conf configuration file on the tag ? – frakorn Feb 24 '12 at 13:17
  • The mapping of a directory to some `index.*` file is done through the `dir_module` which you must also make sure is enabled *(though it more than likely is)*. It sounds like you need a `DirectoryIndex` directive like `DirectoryIndex index.html index.php` added to your ``'s body. Currently `dir_module` is ignoring `index.php`. – deefour Feb 24 '12 at 14:17
  • In the httpd.conf i have the command "DirectoryIndex index.html index.html.var index.php" some rows down the ... block. So you are telling me to copy it and paste it inside the block? (I want to be sure, because i am not the server administrator, so every change must be done by another person). – frakorn Feb 24 '12 at 14:57
  • No, that's not what I'm telling you; if you already have a `DirectoryIndex` containing `index.php` in the main section of the `httpd.conf` that should be enough. Have you been restarting apache after each of the changes to `httpd.conf`? Does a `404` error also come when putting an `index.html` page into the ontowiki directory? Are you sure `dir_module` is enabled? Do you have the same issue for all other hosts running on this Apache install? – deefour Feb 24 '12 at 16:56
  • 1) Yes i've restarted Apache 2) even if i put a index.HTML file, the browser return that he can't find a index.PHP file (i dont know if this is due to that commands in .htaccess file " RewriteRule ^favicon\.(.*)$ application/favicon.$1 RewriteRule !((extensions|libraries).*|\.(js|ico|gif|jpg|png|css|php|swf|json))$ index.php" 3) i have "mod_dir" enabled in my "loaded modules" of Apache 4) I dont know for other hosts – frakorn Feb 24 '12 at 17:42
  • 4) if i create a new folder on public_html with a index.php file, it works – frakorn Feb 24 '12 at 18:36
  • Yeah, we should have removed the contents of the .htaccess file earlier to rule that out. Looking at https://github.com/AKSW/OntoWiki/blob/develop/.htaccess, do you have RewriteBase set properly? – deefour Feb 24 '12 at 18:41
  • I didn't edit my .htaccess file until now, what should i put inside RewriteBase? – frakorn Feb 24 '12 at 19:10