1

I know it was answered on all over the internet, but non of this helped me. I looked even here, didnt help me.

I need to have clear urls

I have this url http://localhost/projekt-vb/index.php?page=example

I need address to be like this localhost/projekt-vb/example

I used this

RewriteEngine on
RewriteRule ^([a-z]+)/?$ index.php?page=$1 [L,QSA]

But for me it didnt solve anything. I know its everywhere but nothing help cant someone write me what I am doing wrong. I am getting mad from it

My file tree is :

projekt-vb/
   admin/
   core/
   modules/
   template/
       cont/
       css/
       imgs/
       example.php
   .htaccess
   index.php

All those files ?page=example lets say, will be placed in template/cont/

Filip Bartoš
  • 179
  • 13
  • 1
    Personally, I prefer putting this sort of stuff directly in the config instead of inside the IfModule tags. It is possible that you have forgotten to load the module, so your config loads, doesn't behave how you want, and never gives an error. – programmerq Oct 24 '16 at 02:43

1 Answers1

2

Original URL: http://localhost/projekt-vb/index.php?page=example

Rewrite URL: localhost/projekt-vb/example

Place you .htaccess file under the folder projekt-vb

RewriteEngine on
RewriteBase /projekt-vb/
RewriteRule ^([a-z]+)/?$ index.php?page=$1 [L,QSA]

When you user url rewrite in localhost, you have to specify folder name on which your project exists, Caused in htdocs or www folder we are you that is our public_html as live website.

So you have to tell folder for you base path for url rewrite.

You file structure must be like this.

projekt-vb/
   admin/
   core/
   modules/
   template/
       cont/
       css/
       imgs/
       example.php
  .htaccess
  index.php

Now in index.php, you can get page as per the below

$pagename=$_GET["page];
Hiren Raiyani
  • 708
  • 1
  • 12
  • 25