fixing URL in Owncloud application to remove requirements to have index.php in url

I have apache 2.2.15. In it I have a virtual directory for owncloud. I am attempting to have http://cargobay.trekfederation.com, however when I type that, my system response with the Apache HTTP Server default page. If I put in http://cargobay.trekfederation.com/index.php, it works. In my .htaccess file, I have tried a series of different RewriteRules to no avail.

The httpd entry looks like this:

<VirtualHost *:80>
ServerName cargobay.trekfederation.com
ServerAlias cargobay.trekfederation.net
DocumentRoot /var/www/html/owncloud
DirectoryIndex index.php index.html
<Directory /var/www/html/owncloud>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>
</VirtualHost>

Open in new window


The owncloud .htaccess file looks like this:

# Version: 8.0.2
<IfModule mod_fcgid.c>
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
</IfModule>
</IfModule>
</IfModule>
<IfModule mod_php5.c>
php_value upload_max_filesize 513M
php_value post_max_size 513M
php_value memory_limit 512M
php_value mbstring.func_overload 0
php_value always_populate_raw_post_data -1
<IfModule mod_env.c>
  SetEnv htaccessWorking true
</IfModule>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php($|\ |\?)
RewriteRule ^ /%1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L]
RewriteRule ^\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L]
RewriteRule ^\.well-known/carddav /remote.php/carddav/ [R]
RewriteRule ^\.well-known/caldav /remote.php/caldav/ [R]
RewriteRule ^apps/calendar/caldav\.php remote.php/caldav/ [QSA,L]
RewriteRule ^apps/contacts/carddav\.php remote.php/carddav/ [QSA,L]
RewriteRule ^remote/(.*) remote.php [QSA,L]
RewriteRule ^(build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
RewriteRule ^(\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
</IfModule>
<IfModule mod_mime.c>
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
</IfModule>
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
        ModPagespeed Off
</IfModule>
<IfModule mod_headers.c>
  <FilesMatch "\.(css|js)$">
    Header set Cache-Control "max-age=7200, public"
  </FilesMatch>
</IfModule>

ErrorDocument 403 /core/templates/403.php
ErrorDocument 404 /core/templates/404.php

Open in new window

LVL 9
Evan CutlerVolunteer Chief Information OfficerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

matrix8086Commented:
did you restart the apache server?
Evan CutlerVolunteer Chief Information OfficerAuthor Commented:
about 26 times. Thanks.
matrix8086Commented:
I tried your site. I does not work with /index.php either.

When I have to go online with a new site, first I am trying a simple stuff to see if the site works. For example yhe index.php contains

<?php
phpinfo();
?>

No restrictions, no .httccess, or other security crazy stuffs. I sugest to try the same and after the site is functional, apply the restrictions and security step by step, to identify possible problems. ;)

Good luck!
Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

Michael MachieIT SupervisorCommented:
You will need to go into your Web Server and set the ownCloud site's default file to 'index.php'. Most Web Servers have index.html or something else set as the default page and changing that to index.php will solve your issue. This has been a standard modification for most every web site out there, including all of mine - ownCloud included.

Evan Cutler: I see you are also using the defualt Branding from ownCloud. If you so choose to change the look, Theme, or Brand your ownCloud feel free to read my Article on Branding ownCloud v.7+8:
Branding ownCloud 7+8
You are also welcome to join my ownCloud Group:
ownCloud Group on Experts Exchange

@matrix8086: The link provided (http://cargobay.trekfederation.com/index.php) loads fine.
Evan CutlerVolunteer Chief Information OfficerAuthor Commented:
ok.  I attempted to do as you asked, and found out that apache is not at fault.  I got phpinfo().  I put in the app, and the app failed again.  This means to me it's something else.  
I tried to update the .htaccess file, with no avail.  here it is again, this time with other information from my httpd.conf

httpd.conf:
<VirtualHost *:80>
ServerName www.trekfederation.com
ServerAlias www.trekfederation.net
ProxyPass / http://www.trekfederation.com:8080/
ProxyPassReverse / http://www.trekfederation.com:8080/
    ProxyPreserveHost on
</VirtualHost>

<VirtualHost *:80>
	ServerName ss51.trekfederation.com
        RedirectPermanent / http://spacestation51.wordpress.com/
</VirtualHost>

<VirtualHost *:80>
ServerName supportchat.trekfederation.com
DocumentRoot /var/www/html/livezilla
<Directory /var/www/html/livezilla>
      AllowOverride All
       Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName supportchat.trekfederation.net
DocumentRoot /var/www/html/livezilla
<Directory /var/www/html/livezilla>
	AllowOverride All
	Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName promenade.trekfederation.com
ServerAlias promenade.trekfederation.net
DocumentRoot /var/www/html/promenade
<Directory /var/www/html/promenade>
      AllowOverride All
       Allow from all
</Directory>
</VirtualHost>


<VirtualHost *:80>
ServerName cargobay.trekfederation.com
ServerAlias cargobay.trekfederation.net
DocumentRoot /var/www/html/cargobay
<Directory /var/www/html/cargobay>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>
</VirtualHost>

Open in new window


and here's my .htaccess (this time it's back to default):
# Version: 8.0.2
<IfModule mod_fcgid.c>
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
</IfModule>
</IfModule>
</IfModule>
<IfModule mod_php5.c>
php_value upload_max_filesize 513M
php_value post_max_size 513M
php_value memory_limit 512M
php_value mbstring.func_overload 0
php_value always_populate_raw_post_data -1
<IfModule mod_env.c>
  SetEnv htaccessWorking true
</IfModule>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L]
RewriteRule ^\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L]
RewriteRule ^\.well-known/carddav /remote.php/carddav/ [R]
RewriteRule ^\.well-known/caldav /remote.php/caldav/ [R]
RewriteRule ^apps/calendar/caldav\.php remote.php/caldav/ [QSA,L]
RewriteRule ^apps/contacts/carddav\.php remote.php/carddav/ [QSA,L]
RewriteRule ^remote/(.*) remote.php [QSA,L]
RewriteRule ^(build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
RewriteRule ^(\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
</IfModule>
<IfModule mod_mime.c>
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
</IfModule>
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
AddDefaultCharset utf-8
Options -Indexes
<IfModule pagespeed_module>
        ModPagespeed Off
</IfModule>
<IfModule mod_headers.c>
  <FilesMatch "\.(css|js)$">
    Header set Cache-Control "max-age=7200, public"
  </FilesMatch>
</IfModule>

Open in new window



my fear is that I have a global somewhere I am missing....but I did the phpinfo() test and it worked fine.
Michael MachieIT SupervisorCommented:
@Evan: We posted at the same time and mine was put before yours, so please make sure to give my suggestion a quick review.
Evan CutlerVolunteer Chief Information OfficerAuthor Commented:
Hi @Machienet, I was just reading it.  In the middle of.htaccess sits:
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>

Open in new window


what am I missing?
Michael MachieIT SupervisorCommented:
I now realize that you are trying to perform that exact process I mentioned to try, and what you show is actually the file config to do so.

Please try separating the lines out instead of adding in one line:
<Directory /(owncloud folder)
DirectoryIndex index.php
DirectoryIndex index.html
</Directory>

In your code above it seems you have specified '<IfModule mod_dir.c> as your site directory. Is that your ownCloud site directory?
Michael MachieIT SupervisorCommented:
My apologies, you want to make that edit in httpd.conf file.
Evan CutlerVolunteer Chief Information OfficerAuthor Commented:
no dice.
It requires: http://cargobay.trekfederation.com/index.php/apps/files/
to execute.

where else do I look?
Michael MachieIT SupervisorCommented:
You have the proper spot - truly.
The default /apps/files page is your default landing page once you are logged in.

When you state: 'It requires: http://cargobay.trekfederation.com/index.php/apps/files/', what requires this?
Evan CutlerVolunteer Chief Information OfficerAuthor Commented:
perfect.  we are in sync.
I don't know what requires the infusion of "index.php" in the URL in order for it to work.
What I'm trying to do is:
http://cargobay.trekfederation.com/apps/files/

That fails.  Where do I go from here?
Thanks for the time by the way.
Michael MachieIT SupervisorCommented:
Ahh I see now. You cannot specify that as your default page and any attempts to do so will fail.

However, I forget the syntax off-hand, but I believe you need to add a line specifying a Fallback in case the supplied URL [http://cargobay.trekfederation.com/apps/files/] does not have /index.php at the end. The Fallback allows the Server to route to the default page when it does not recognize the full URL as a legit page. However, there are Security concerns with going that route.

The best practice for ownCloud is ti set the default page on the site to /index.php and provide a link to the web site - www.domain.com. When they hit the link it drops at your specofoed page of /index.php - for login - and then when logged in ownCloud directs to /apps/files.

Is this making sense to you? Trying to write this on my cell while traveling down a bunpy road that is distracting me haha.
Michael MachieIT SupervisorCommented:
Oh, to explain why index.php is required at all.

Index.php is the file containing the code that allows authentication to the DB. Without the coding in index.php you cannot log in. This file could be named anything at all, but index.php is an Industry Standard, as is index.html and home.aspx, depending on which language you use to build the site. Without using a Standard, 3rd party mods and hooks would be nearly impossible to implement on a large scale.

In this case we use index.php because ownCloud uses PHP as the coding language. The site needs to know which (PHP) file to point to in order to perform it's function - log in and access files. Index.php is the file, so index.php is required in the path.

Setting the default page to index.php on the site allows redirection if index.php is not part of the path.
Evan CutlerVolunteer Chief Information OfficerAuthor Commented:
Hi, thanks.  Had to travel home.  ok.  I'm with you there...but most frameworks do not require you to have index.php in the URL, but owncloud does.  why?  in most cases views used in an application will allow for the use of the URL slash as an end point.  What does owncloud do to prevent you from just typing the domain?  why must there be domain/index.php in the address bar of the browser?

Thanks.
Michael MachieIT SupervisorCommented:
I see what you are saying, sorry for misunderstanding.

I do not have any specific technical answer or that question. All I can say is I noticed all of my PHP based web sites require it. Im not sure if that is normal or not. Never really took notice of that before.

Let us know how the edits work for you.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Evan CutlerVolunteer Chief Information OfficerAuthor Commented:
I'm sorry.  I thought I closed this before.
I appreciate all of your answers.  I just told my users to add the index.php for now.
Maybe a question to answer later on.

Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.