How to create custom URL routes?

Add this to your theme’s functions.php, or put it in a plugin. add_action( ‘init’, ‘wpse26388_rewrites_init’ ); function wpse26388_rewrites_init(){ add_rewrite_rule( ‘properties/([0-9]+)/?$’, ‘index.php?pagename=properties&property_id=$matches[1]’, ‘top’ ); } add_filter( ‘query_vars’, ‘wpse26388_query_vars’ ); function wpse26388_query_vars( $query_vars ){ $query_vars[] = ‘property_id’; return $query_vars; } This adds a rewrite rule which directs requests to /properties/ with any combination of numbers following to … Read more

Getting a 500 Internal Server Error on Laravel 5+ Ubuntu 14.04

Finally Overcame the problem It was not the .htaccess file that was the problem nor the index.php. The problem was on accessing the files and requiring permissions. For solving the problem i ran the following commands through terminal. and then type below to allow laravel to write file to storage folder This two commands solved … Read more

How does RewriteBase work in .htaccess

In my own words, after reading the docs and experimenting: You can use RewriteBase to provide a base for your rewrites. Consider this This is a real rule I used to ensure that URLs have a trailing slash. This will convert to By having the RewriteBase there, you make the relative path come off the RewriteBase parameter.

htaccess – Redirect to subfolder without changing browser URL

Sorry, just realised what is happening. It has nothing to do with the second .htaccess file in the subdirectory, as mentioned in comments. Since public is a physical directory on the file system, you need to include a trailing slash when internally rewriting to that directory. Otherwise, mod_dir is going to try to “fix” the … Read more

How to enable mod_rewrite for Apache 2.2

In order to use mod_rewrite you can type the following command in the terminal: Restart apache2 after or or as per new unified System Control Way Then, if you’d like, you can use the following .htaccess file. The above .htaccess file (if placed in your DocumentRoot) will redirect all traffic to an index.php file in the DocumentRoot unless the file exists. So, let’s say you have … Read more

.htaccess – how to force “www.” in a generic way?

I would use this rule: The first condition checks whether the Host value is not empty (in case of HTTP/1.0); the second checks whether the the Host value does not begin with www.; the third checks for HTTPS (%{HTTPS} is either on or off, so %{HTTPS}s is either ons or offs and in case of ons the s is matched). The substitution part of RewriteRule then just merges the information parts to a full URL.