[SOLVED]How to hide index.php in Linux ?

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!

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

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.

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

By the check this cookbook

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

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.

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.

@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:

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

[font=courier][size=3]sudo a2enmod rewrite[/size][/font]

Step 2: Give permission to you are as root to modify the [size=2][font=courier]default[/font][/size] file

[font=courier][size=3]sudo chown admin:admin /etc/apache2/sites-available/default[/size][/font]

Step 3:

Go to the etc/apache2/sites-available/default, and open the [font=courier]default[/font] with Text Editor.

Step 4:

Find these lines of code

Step 5: Restart your apache

[size=3][font=courier]sudo /etc/init.d/apache2 restart[/font][/size]

It should now work!

Quote

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

Just a short name for “virtual host”.