Page 1 of 1

Error when Hide index.php on server

PostPosted: Wed Jun 24, 2015 7:14 am
by Whortiter
Hi! I am using Yii and currently i am trying to hide the index.php from my URL. I have hosted my project on hostforlife server. The contents of my .htaccess file are

Code: Select all
<ifModule mod_rewrite.c>
Options -Multiviews
Options +FollowSymLinks
# Turn on the engine:
RewriteEngine on
# Don't perform redirects for files and directories that exist:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For everything else, redirect to index.php:
RewriteRule . index.php
</ifModule>


and in the config/main.php showScriptName=>False

I searched about it a lot and found that adding Options -Multiviews solves the problem. But it didnt work for me. It shows 404 - File or directory not found. So any help will be appreciated

Re: Error when Hide index.php on server

PostPosted: Wed Jun 24, 2015 4:54 pm
by Gecko
Whortiter,

If you're trying to hide the index.php for your URL http://your-domain.com/index.php so it just shows http://your-domain.com and loads the index'php page then try this in your htaccess file.

Code: Select all
<ifModule mod_rewrite.c>
# Turn on the engine:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</ifModule>


As for the Options -Multiviews and Options +FollowSymLinks they would have to come after the rewrite engine is turned on, but I don't think you'll need them.