Saif Ali
Saif Ali

Reputation: 427

.HTACCESS Apache Mod_Rewrite not working

I have tried to manage my website's requests from http://example.com/index.php/register to http://example.com/register

But it always shows no input file specified.

Now all i want to do is to remove the /index.php and rewrite the requests. here is my .HTACCESS file i have tried multiple things but no luck.

 <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Just let me know where the issue is.

Upvotes: 0

Views: 1953

Answers (3)

Dusan Bajic
Dusan Bajic

Reputation: 10889

Can you try this:

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/index.php
RewriteRule ^(.*)$ /index.php/$1 [L] 

Upvotes: 1

Ravi Hirani
Ravi Hirani

Reputation: 6539

No need to write RewriteBase /

Use below htaccess.

# Turn mod_rewrite on
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L] 
# add / before index.php

Hope it will work :-)

Upvotes: 2

Ehsan Gazar
Ehsan Gazar

Reputation: 81

There may be some reasons for not working this code

First - Allow override in apache config, You should know where is your apache config, usually it is in the /etc/apache2/sites-available/default

<Directory "/path/to/document/root/">
  AllowOverride All
  Allow from All
</Directory>

Second - mod_rewrite is not enable, so you should enter this command for enabling that.

sudo a2enmod rewrite
sudo service apache2 restart

Third - If still your rewrite mode doesn't work, or you don't have an access to change the config of the server you can see your register page like this: http://quepos.fishing/index.php/register

Upvotes: 1

Related Questions