0

this is my simple htaccess that redirect all calls to index.php or to error.php

It work fine but I would hide the original address from the address bar.

#Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$  [NC]
RewriteRule (.*) index.php [L]

ErrorDocument 404 /error.php

Now if I go on www.mysite.com/news/last I can view www.mysite.com/index.php?p=news&section=last but I wish it did not change in the address bar.

Thanks in advance ;)

1 Answers1

0

Since you are redirecting all the calls to the index.php file, i guess you have to build a router in php (or try to use one already built). Then you have to configurate (via xml or php configuration file normally) the routes with wich you want to replace the original query strings. example:

index.php?p=news&section=last

can become

/news/last

or whatever string you prefer. If you need examples or help how to create a routing system, just ask =)

Cheers

AlexFr.
  • 354
  • 2
  • 12
  • First of all thank you for the answer ;) I did not understand what is the router... I send all calls to the index.php file, retrieve the informations from $_SERVER[uri] and switch the calls with the function header('location:'.$redirect); What is wrong? Why the address bar change from "www.mysite.com/username" to "www.mysite.com/index.php?un=username"? I would like to keep the "www.mysite.com/username" – user1075086 Dec 06 '11 at 22:22