Remove /index.php/ from the url

How can I remove /index.php/ from the url? I’ve tried various htaccess solutions from another thread but it does not work.

1°) what kind of server you are running on ? Shared Hosting, Private Server, Real server ? Apache Ngnix ?

2°) Normaly if everything is well configured, you don’t have to do anything, index.php isn’t there. So you have a problem with your .htaccess, the one packed in nextcloud.zip works.

I just copied and pasted the content of nextcloud.zip, and I am running Apache on a private server.

For me when i do

cp -R /nextcloud/* /var/www/nextcloud/

i didn’t have .htaccess and .user.ini copied i have to do it manually

cp -R /nextcloud/.htaccess /var/www/nextcloud/.htaccess

same thing when i set permissions :

chown -R www-data:www-data /var/www/nextcloud/*

chown www-data:www-data /var/www/nextcloud/.htaccess

I’m also having trouble with this, using the the .htaccess provided in the NC10 package I proceeded to add “‘htaccess.RewriteBase’ => ‘/’,” to my config file and then I ran “sudo -u apache php occ maintenance:update:htaccess” to update the htaccess file.

Upon opening Nextcloud in a browser I received a 503 response - the Apache error log isn’t getting hit at all which is confusing. In my requests log I see this:

192.168.1.100 - - [25/Aug/2016:20:05:25 +0100] “GET /login HTTP/1.1” 503 - “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36”
192.168.1.100 - dominic [25/Aug/2016:20:05:37 +0100] “PROPFIND /remote.php/webdav/ HTTP/1.1” 207 409 “-” “Mozilla/5.0 (Windows) mirall/2.2.2 (build 6192)”
192.168.1.100 - dominic [25/Aug/2016:20:05:59 +0100] “PROPFIND /remote.php/webdav/ HTTP/1.1” 207 408 “-” “Mozilla/5.0 (Windows) mirall/2.2.2 (build 6192)”
192.168.1.100 - dominic [25/Aug/2016:20:06:00 +0100] “GET /ocs/v2.php/apps/notifications/api/v1/notifications?format=json HTTP/1.1” 200 74 “-” “Mozilla/5.0 (Windows) mirall/2.2.2 (build 6192)”
192.168.1.100 - dominic [25/Aug/2016:20:06:02 +0100] “PROPFIND /remote.php/webdav/ HTTP/1.1” 207 10242 “-” “Mozilla/5.0 (Windows) mirall/2.2.2 (build 6192)”
192.168.1.100 - dominic [25/Aug/2016:20:06:02 +0100] “PROPFIND /remote.php/webdav/Google%20Drive HTTP/1.1” 207 2682 “-” “Mozilla/5.0 (Windows) mirall/2.2.2 (build 6192)”
192.168.1.100 - - [25/Aug/2016:20:06:05 +0100] “GET /login HTTP/1.1” 503 - “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36”
192.168.1.100 - - [25/Aug/2016:20:06:06 +0100] “GET /login HTTP/1.1” 503 - “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36”
192.168.1.100 - - [25/Aug/2016:20:06:07 +0100] “GET /login HTTP/1.1” 503 - “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36”
192.168.1.100 - - [25/Aug/2016:20:06:10 +0100] “GET / HTTP/1.1” 302 - “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36”
192.168.1.100 - - [25/Aug/2016:20:06:10 +0100] “GET /login HTTP/1.1” 503 - “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36”

I’m running Nextcloud on a dedicated machine at home which is running Fedora - Nextcloud is configured as a virtualhost and is bound to a subdomain i.e. cloud.domain.com. Mod Rewrite is installed and loaded by Apache correctly.

It’s been resolved before: Apache rewrite to remove index.php - #2 by LukasReschke

Just add 'htaccess.RewriteBase' => '/', in your config.php, then run run occ maintenance:update:htaccess

1 Like

As stated already done that.

Can you paste the output of your htaccess file?

Have you bounced the apache service?

htaccess file is here:
http://pastebin.com/xWKibnxk

Not sure what you mean by bounce, restart? Restart produces no changes.

Sorry I was addressing @joery

There maybe also an issue with apache configuration.
check if you have mod_env and mod_rewrite enabled
check if you have AllowOverride All as since 2.3.9 and later it’s set to none by default

your .htaccess looks ok

1 Like

Yep checked all that also.

mod_rewrite is definitely working as am using it elsewhere

Sorry, local colloquialism.

Do you get the same 503 if you try re-adding the index.php manually back to the URL? If so:
Are you able to reverse the changes and restore a working instance?

Or perhaps if you’re not against it, pull down a fresh NC zip and install into a subdir. Execute the same changes on that and see if you can replicate the issue? That’d rule out enabled apps and such.

Yes if I add index.php back into the URL the rewrite rules come into play and it gets stripped out. Reversing the changes i.e. removing the RewriteBase directive from the config file and running the update htaccess command brings it back into a working installation.

On a test instance on the same system with no apps enabled also produces the similar results - I’m able to get a login screen but that’s only because it’s being served from the root as oppose to /login (with 2FA authentication enabled) - proceeding past the login screen to /files results in a 503.

Turns out my own rewrite rules to force https were interfering with this - since Nextcloud can force https for you they were not needed; all working now!

Thanks guys!

Actually since doing this I’m now getting this in the admin panel:

“Your data directory and your files are probably accessible from the Internet. The .htaccess file is not working. We strongly suggest that you configure your web server in a way that the data directory is no longer accessible or you move the data directory outside the web server document root.”

I’ve tried accessing /data via a browser and just redirects to Nextcloud, so I’m not sure what it’s complaining about.

Yeah, had the same thing here, so I just moved it out of the webroot.

Relatively common complaint with no real solid answer. I don’t get it, and my htaccess was built by NC.

Yeah ended up moving my data directory up a level, it was just one line in the config.php so no real effort was needed and to be honest it’s more secure anyway.

Only side effect I’ve observed is that the login page is now triggering an refresh in the browser every 5 seconds, obviously extremely annoying for people who don’t type very fast and/or have long passwords; it is literally 5 seconds having timed it. Any ideas anyone? I do have two factor authentication set up, if that’s of any relevance.

I believe it was @tflidd the other day who said moving the data dir after installation was not supported and may cause issues.

@JasonBayton: Yes that’s still an issue.