I am working on a project and i am putting SEO in mind, the smartest way around this will be to dynamically create a none existing page.
Details
i have a list of towns
- Texas
- Delhi
- Toronto
- Sydney
This are links that look like http://xxxxx.com/texas
**Note:**there is no file named texas.php
I have a template page that fetches from the database base on the town clicked on.
I want the link to look like this http://xxxxx.com/schools-in-texas
That should display a page with the template showing results from database after querying the DB with the work “texas”
this should apply for other towns e.g http://xxxxx.com/schools-in-toronto
2
Answers
First you should route any Not Found pages to a php script.
In you
.htaccess
file:Then you can get the URL as a string and get the part you need.
for example if you visit yoursite.com/Texas the following script will return
/Texas
:and you can do any further work on database…
(The htaccess code got from the Laravel’s)
You have to use apache’s mode-rewrite rules. With that you could parse your URL and set your GET-String parameters to be used in your controller file that is responding to your page request.
Here is a simply tutorial:
Mod-rewrite tutorial