Yii Framework Forum: [SOLVED]How to hide index.php in Linux ? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

[SOLVED]How to hide index.php in Linux ? Rate Topic: -----

#1 User is offline   revo110 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 04-March 09

Posted 31 May 2009 - 08:33 PM

Hi,

I've read and done URL Rewriting using the URL Management as stated in:
http://www.yiiframew...uide/topics.url

Sadly, I can't make it work in Linux (Xubuntu 9.04), it always shows Page Not Found Error. But it works well in Windows. Are there any particular settings that I must configure at apache2.conf before I can start using .htaccess ? Any help would be greatly appreciated.

Note:
For Linux and Windows, I am using LAMP Server.

Thank you!


0

#2 User is offline   Deepak Pradhan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 209
  • Joined: 01-May 09
  • Location:Charlotte, NC

Posted 31 May 2009 - 09:07 PM

I could also not get the url rewrite to work using urlManager.

This is how my .htaccess looks like, it does not hide but I do not put index.php=r in my url:
##  Can be commented out if causes errors, see notes above.
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On

# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?r=$1

0

#3 User is offline   revo110 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 04-March 09

Posted 31 May 2009 - 10:26 PM

Quote

I could also not get the url rewrite to work using urlManager.



This is how my .htaccess looks like, it does not hide but I do not put index.php=r in my url:

##  Can be commented out if causes errors, see notes above.

Options +FollowSymLinks

IndexIgnore */*

RewriteEngine On



# RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*) index.php?r=$1


What's your OS ? Linux, Mac, or Windows ?

I used the given .htaccess at the tutorial, and it works fine in Windows LAMP Server (default installation with no additional settings). But in Xubuntu 9.04 or in Linux,  it does not work, so I guess there must be some setting to be set first in the apache configuration file in order to read .htaccess. But I am not sure...

I hope someone can answer this soon.

Thanks.
0

#4 User is offline   Deepak Pradhan 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 209
  • Joined: 01-May 09
  • Location:Charlotte, NC

Posted 31 May 2009 - 10:56 PM

It is working for me in Windows and Linux (with hostmontser).

By the check this cookbook
http://www.yiiframew...oc/cookbook/15/
0

#5 User is offline   dubby 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 10-February 09
  • Location:Melbourne, Australia

Posted 31 May 2009 - 11:21 PM

mod_rewrite might not be running with apache. When you say you are running Lamp I assume you are running this form your home server and therefore have control over it.

If using a Debian/*buntu server you can enable this module by running


Then restart Apache and try again.
0

#6 User is offline   revo110 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 04-March 09

Posted 01 June 2009 - 12:46 AM

Quote

It is working for me in Windows and Linux (with hostmontser).



By the check this cookbook

http://www.yiiframew...oc/cookbook/15/


@foe: Is that if I install PHP as CGI ?

Quote

mod_rewrite might not be running with apache. When you say you are running Lamp I assume you are running this form your home server and therefore have control over it.



If using a Debian/*buntu server you can enable this module by running





Then restart Apache and try again.


@dubby: Thanks, I have done what you have told me, but still I got Page Not Found error. Any other ideas ? Because I am new in Linux, and right now, I am feel kinda stuck.
0

#7 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,013
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 01 June 2009 - 03:45 AM

@revo110:
Did you install in the web root folder of your Vhost? If not, try to set RewriteBase. E.g. if your app is reached with http://example.com/myapp/index.php:

0

#8 User is offline   revo110 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 78
  • Joined: 04-March 09

Posted 01 June 2009 - 04:36 AM

Quote

@revo110:

Did you install in the web root folder of your Vhost? If not, try to set RewriteBase. E.g. if your app is reached with http://example.com/myapp/index.php:



@Mike: Thank you! What's a VHost by the way ?

But I have found another way to make the url rewrite works in Linux, I do not know if this is the correct one to do it but it works for me:

Open your terminal and follow these steps:

Step 1: Enable the mod_rewrite module
sudo a2enmod rewrite

Step 2: Give permission to you are as root to modify the default file
sudo chown admin:admin /etc/apache2/sites-available/default

Step 3:
Go to the etc/apache2/sites-available/default, and open the default with Text Editor.

Step 4:
Find these lines of code


Step 5: Restart your apache
sudo /etc/init.d/apache2 restart

It should now work!
0

#9 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,013
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 01 June 2009 - 11:49 PM

Quote

@Mike: Thank you! What's a VHost by the way ?


Just a short name for "virtual host".
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users