• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mod rewrite problem with Ubuntu

#1
[eluser]Mohammed Zayan[/eluser]
I use Ubuntu and enable mod_rewrite in Ubuntu by:
Code:
sudo a2enmod rewrite
and I have restart the server by:
Code:
sudo /etc/init.d/apache2 restart

and I use this code in .htaccess file
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /zayanit/

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

when I use:
http://localhost/zayanit/site/index
I have this error:
The requested URL /zayanit/site/index was not found on this server.
Apache/2.2.17 (Ubuntu) Server at localhost Port 80
but if I put index.php in url it works.

So what is the problem?!!

#2
[eluser]WanWizard[/eluser]
Your rewrite rule is looking for /index.php, is it in the root of the docroot?

#3
[eluser]Mohammed Zayan[/eluser]
Yes
And when I write
http://localhost/zayanit/index.php/site/index
in the url the page working without any problems

#4
[eluser]WanWizard[/eluser]
Are you using a fastCGI installation? If not, the question mark should not be part of the rewrite rule.

so
Code:
RewriteRule ^(.*)$ /index.php/$1 [L]

#5
[eluser]Mohammed Zayan[/eluser]
I don't know what is fastCGI installation so, I think I don't use it. And I remove the question mark from the rewrite rule.
My code now is
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /zayanit/

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

It still doesn't work

#6
[eluser]Mohammed Zayan[/eluser]
What should I do to solve it?

#7
[eluser]CroNiX[/eluser]
Try this by itself. If it doesn't work, try removing the ?. I use this on Ubuntu 10.04 (except I don't need a RewriteBase). The rest of that is unneeded for CI 2+
Code:
RewriteEngine On
RewriteBase /zayanit/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]


Also, I think the problem might be with your if blocks. On my server, the extensions are .so, not .c. If you use the above this will probably confirm that.

#8
[eluser]Mohammed Zayan[/eluser]
I try
Code:
RewriteEngine On
RewriteBase /zayanit/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

And
Code:
RewriteEngine On
RewriteBase /zayanit/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

It doesn't work. I use Ubuntu 11.04


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.