0

I've read tons of other answers about this case but nothing helped. I have this website http://allutas.com with the following folder structure

Allutas
 Application 
   Controllers
      index.php
   Models
   Views
 System
 index.php

when you visit http://allutas.com the index page performs some checks and if everything is right it sends the user to Application/Controllers/index.php

and all the other pages that the user can visit are located in that Controllers folder too

so simply what I'm trying to do is to remove or hide the subdirectories part in my website from all the files in the controller folder along with the .php extension so instead of

http://allutas.com/Application/Controllers/index.php or http://allutas.com/Application/Controllers/about.php

I want it to be like that

http://allutas.com/index or http://allutas.com/about

I've tried a lot of other answers and they ended up doing nothing or cause a 500 internal server error

here's an example of an htaccess file that is gonna give a 500 internal server error

 <IfModule mod_rewrite.c>
 RewriteEngine On    
 RewriteRule ^(.*)$  application/controllers/$1 [L]
 </IfModule>

If it helps, my host is using Apache version 2.4.3-25 and PHP version 5.6.27

Omar Abdo
  • 1
  • 1

2 Answers2

0

Can you try this -

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

It should work for these type of links: http://allutas.com/about.php http://allutas.com/index.php

0

In the .htaccess file you:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule  ^(.+)$ index.php?url=$1 [QSA,L]

Goes to index. Sets a $_GET['url'] to whatever comes after the domain name of the site.

In your index.php file (next to the .htaccess file): you should be able to get the content of the $_GET['url'] easily without any trouble!

$url = $_GET['url'];
echo $url;

This is what you'll get:

Text1/Text2/Text3

Commonly it's used like,

  1. text1 refers to a controller
  2. text2 refers to an action
  3. text3 refers to a params

Do whatever you want with it!

Ahmed Abaza
  • 89
  • 1
  • 7