In my index.php I have a list of properties. When I click on it, it directs me to property_detail.php but with extra details on the URL making it very long and untidy. How to make it short?
Asked
Active
Viewed 90 times
0
-
4Google "url rewriting" – Charlotte Dunois Jul 11 '16 at 08:26
-
By mapping a given set of parameters to an unique ID. You can store these information wherever you want, as long as you can retrieve it from `property_detail.php`. – Matt Jul 11 '16 at 08:27
-
You may want to look at using POST requests since this will remove the need for URL parameters. – Daniel Waghorn Jul 13 '16 at 09:47
-
Possible duplicate of [URL rewriting with PHP](https://stackoverflow.com/questions/16388959/url-rewriting-with-php) – giorgio Sep 14 '17 at 06:28
-
@DanielWaghorn POST vs GET have different goals. You should not want to POST stuff if you don't actually want to persist data. – giorgio Sep 14 '17 at 06:30
1 Answers
0
Set rewrite URL rule in .htaccess
in the root folder.
RewriteEngine On
RewriteCond $1 !^(index\.php|assets|images|js|css|upload|favicon.png)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Nathan Tuggy
- 2,237
- 27
- 30
- 38

Touqeer Fazal
- 1
- 1
- 5