Using slugs in codeigniter

I just store the slugs in my database table, in a column called slug, then find a post with the slug, like this: public function view($slug) { $query = $this->db->get_where(‘posts’, array(‘slug’ => $slug), 1); // Fetch the post row, display the post view, etc… } Also, to easily derive a slug from your post title, … Read more

Clean URLs for search query?

I think the problem is that you’ve created an HTML form with GET method, which automatically opens the URL that way you specified as the result. If you want to submit your search query like the desired one, you should hack the form with some JavaScript to call your good-looking URL like this: <form method=”get” … Read more

Enable clean URL in Yii2

I got it working in yii2. Enable mod_rewrite for Apache. For basic template do the following: Create a .htaccess file in web folder and add this RewriteEngine on # If a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Otherwise forward it to index.php RewriteRule . index.php Then … Read more

Remove .php extension with PHP

If you’re serving via Apache, you’ll want to look at mod_rewrite. Using mod_rewrite, you can modify how URLs are mapped to your application’s actual end-points. For your example, you’ll want something like this: RewriteEngine on RewriteRule ^/?page/(.*)$ page.php/$1 [L] This page has some other simple examples.

How to version REST URIs

Do not version URLs, because … you break permalinks The url changes will spread like a disease through your interface. What do you do with representations that have not changed but point to the representation that has? If you change the url, you break old clients. If you leave the url, your new clients may … Read more