• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trying to get rid of index.php from address on my ubuntu system

#1
Hi all,

I have setup a laptop with ubuntu on it and I have setup LAMP and everything is working (connects to database and site show up) I have installed Webmin too so I can access things.  I now have a small issue of getting rid of the index.php from my addresses (if its in my links the pages work, but I don't want it there). I have gone into apache2 and enabled rewrite like I do on my windows WAMP system but I am still getting page not found errors Sad

I have even put in a .htaccess file to see if it will work but nothing.  my phpinfo is showing that mod_rewrite it loaded but I am pulling my hair out why its not working.

Can anyone please help?

Thanks,
Doomie
Reply

#2
you can read this https://codeigniter.com/user_guide/gener...x-php-file

and in config.php you find this:
Code:
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = 'index.php';
"Make it idiot proof and someone will make a better idiot."
Reply

#3
Should be like this:


PHP Code:
$config['index_page'] = ''

And make sure your apache config has AllowOverride all

Locally, you'll want to use an .htaccess with something like this:


Code:
RewriteRule .* index.php/$0 [PT,L]
Reply

#4
Thank you for your replies, but at this moment nothing seems to get rid of it.  I have tried the following:

I have change this in /etc/apache2/apache2.conf

Code:
<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>


I have also added the .htaccess to have this

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

and also this one

Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

I have also made sure that in config.php it is set as

Code:
$config['index_page'] = '';

and just incase 

Code:
$config['index_page'] = 'index.php';


I have used phpinfo() to display on the server and in the loaded modules it says mod_rewrite.

but yet if I have it as the page http://localhost/ it shows the home page as normal, but if I say go into http://localhost/blog it cannot find it.  I add index.php into the address and it works.

I have had this exact project in WAMP on windows working fine and also on my linux hosting and it also works fine there.  I just don't see what could be making the issue. Sad
Reply

#5
There may be more than one location in /etc/apache2/apache2.conf where AllowOverride would need to be changed. I've made that mistake myself ...
Reply

#6
ohk so got to your terminal and sudo nano /etc/apache2/apache2.conf. edit the file and change all AllowOverride None to AllowOverride All.
After that you need to enable mod rewrite by typing sudo a2enmod rewrite, after which you restart the server using sudo /etc/init.d/apache2 restart.

I think that should do the trick. If it doesnt youll have to look inside your .htaccess file.
Reply

#7
Tried all that but it wasn't what the issue is (I have found the issue).  So this is here if anyone else has the issue.

What I found out is for some reason the .htaccess file wasn't showing as a .htaccess file type (could of happened with mixing with windows, I don't know) it was instead showing as just a file.  So I grabbed it all again from my git and copied the folder in instead and noticed that looking at the folder in files on ubuntu you cannot see the .htaccess file, but in terminal you can.

So if you ever have this kind of issue, check your .htaccess, if you can see it in files then there is an issue.

Thanks to all that helped me narrow down this issue.
Reply

#8
(03-01-2017, 05:08 AM)doomie22 Wrote: ... (could of happened with mixing with windows, I don't know) ...


Friends don't let friends mix with windows Big Grin
Reply

#9
(03-01-2017, 06:29 PM):Dskunkbad Wrote:
(03-01-2017, 05:08 AM)doomie22 Wrote: ... (could of happened with mixing with windows, I don't know) ...


Friends don't let friends mix with windows Big Grin

lol Big Grin Big Grin Big Grin
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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