- #Mamp wordpress htaccess rewrite rule not working how to#
- #Mamp wordpress htaccess rewrite rule not working windows#
If we type in the URL then $1 will be equal to “hello”, so we will retrieve the information at index.php?page=hello. Since there was only one regular expression in this command, the $1 represents that. Each variable corresponds to a regular expression. You’ll notice that we have a $1 in there. The next part of the command is the file we want to go to from the pretty URL, in this case index.php?page=$1.
Basically what this one is saying, is it will accept any combination of lowercase letters ( a-z), uppercase letters ( A-Z), and numbers ( 0-9).įinally the $ tells us the end of the pretty URL. If you aren’t familiar with regular expression, there is a great online tool to test them out located here. Next we have a regular expression surrounded by brackets. This would change depending on what directory you put your. The carat symbol signifies the base URL, in this case. Next we have the format of the pretty URL, which looks like ^(+)/$. This tells Apache we want to start a rewrite. First, we have the call to the RewriteRule command. Let’s break down the command above piece by piece. First is the format of the pretty URL followed by the actual place the URL will go on the server. To tell Apache to forward our pretty URL to our index.php file, we use the RewriteRule command. For example, if we want the member page, the request would be index.php?page=member, so the URL would look like. For the sake of this tutorial, I’ll assume all incoming requests are going to be handled by index.php using a get variable to tell us what page to retrieve. Next we want to take a look at forwarding a link. This tells Apache we want to make our own rules. To do this, you just need to enter the following command as your first. The first thing we want Apache to do is recognize we want to create our own rules. htaccess file, or if you don’t have one yet, create one.htaccess Commands Once here, check to make sure you can see invisible files. This directory will most likely be called httpdocs. FTP into your server and navigate to your site’s main directory.
#Mamp wordpress htaccess rewrite rule not working how to#
Now that we know why we want pretty URL’s, let’s take a look at how to actually get them. Some web spiders will avoid ugly and convoluted URL’s. They are also more likely to be crawled by web spiders (which I go over in my SEO Tips & Tricks for WordPress post). One of the biggest advantages to pretty URL’s (other than the fact they’re pretty) is they are much more memorable for visitors to your site. Something like would be a lot more desirable. This is obviously not a very good looking URL.
Let’s saying you have a URL that looks something like. htaccess file is better set in a Directory block, as it will have the same effect with better performance. htaccess files slows down your Apache http server. htaccess files completely if you have access to httpd main server config file. htaccess file is good for, you can also control authorization, blocking, MIME types, and more…īefore we get started, please note the following warning from Apache: In this tutorial, I want to go over how to make pretty URL’s using this file. It allows you to provide a way to make configuration changes on a per-directory basis.
#Mamp wordpress htaccess rewrite rule not working windows#
htaccess file is one of the most powerful tools available on your Apache server (this only works on Apache, so Windows users must find their fun somewhere else).