Archive for the ‘apache’ Category
Apache redirect examples using mod_alias
Hi! here I will provide few samples of how to create redirect in Apache web server. You can test this examples locally in your localhost.
First example
In the first example let’s redirect to Google search when we trying to go to localhost.
1. Go to the root folder of your web server. In my case, it’s C:\xampp\htdocs\.htaccess and create .htaccess file if it doesn’t exist.
2. At the first line of .htaccess write:
Redirect / http://google.com4. Try to go to your localhost again. Apache will redirect you to Google search.
Second example
In this example le’ts redirect to Google search only when somebody trying to go to a web server folder “my”.
1. At the first line of .htaccess write:
Redirect /my/ http://google.com2. Now, when you go to your localhost you will get the right localhost page, but when you try to go to http://localhost/my/ it redirects you to Google search.
Third example
1. Let’s redirect to a subfolder when querying a subfolder. For instance, when the user entering http://localhost/my/ let’s redirect to http://localhost/site/ or when the user querying http://localhost/my/page.html let’s redirect to http://localhost/site/page.html
2. Edit your .htaccess:
Redirect /my/ /site/mod_alias
All these tricks are done with help of mod_alias so this module has to be turned on. You can read more abous this module at Apache:
Apache doesn’t start in XAMPP
I’ve already had this problem a lot of times. Apache does not start in XAMPP. I’ve had this problem in my computers and computers of my friends. As I know based on my practice, the key of this problem is in ports. Because ports that Apache uses are busy it cannot start.
By default, Apache listens a port number 80 for HTTP and a port number 443 for HTTPS.
In your system other web server may run. For example, Internet Information Services (IIS) or something else. This web server can use ports that Apache needs, I mean 80 and 443. In this way, to fix the problem you need to change the default numbers of ports of Apache or numbers of ports of the other web server that runs on your system. To change this values find Listen command in these files and change the value:
- C:\xampp\apache\conf\httpd.conf
- C:\xampp\apache\conf\extra\httpd-ssl.conf
If you have Skype it also uses these ports. In this way, to fix the problem you should uncheck the usage of these ports in Skype settings or change the numbers of ports using the method above.
