Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use .htaccess in WAMP Server?

I searched in web for 2 days and I try to use htaccess in my local wamp but I can't! I know there is something wrong but I don't know where...

First: I activated "rewrite_module" in the apache menu, then I checked the phpinfo page and I saw that module added to its "Loaded Modules" part.

Second: I checked the httpd.conf and made some changes, it is the result (just important parts):

ServerRoot "c:/program Files/wamp/bin/apache/apache2.2.11" Listen 80 ServerName localhost:80 DocumentRoot "c:/program Files/wamp/www/"  <Directory /> Options FollowSymLinks # AllowOverride None # Order deny,allow # Deny from all AllowOverride all Order Allow,Deny Allow from all </Directory>  <Directory "c:/program Files/wamp/www/"> Options Indexes FollowSymLinks AllowOverride all Order Allow,Deny Allow from all </Directory>  LoadModule alias_module modules/mod_alias.so LoadModule rewrite_module modules/mod_rewrite.so 

Next: I made an alias to my workspace. Here is contents of its .conf file:

Alias /basic_test/ "e:/Projects/basic_test/"  <Directory "e:/Projects/basic_test/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all </Directory> 

Next: I place a simple "index.php" and "test.php" in my workspace root and tested the alias by this addresses: --> "localhost/basic_test/index.php" --> "localhost/basic_test/test.php" They worked perfectly...

Finally, I added a ".htaccess" file to the root of my workspace (beside index.php), and I wrote in it:

<IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^index.php$ test.php </IfModule> 

But the problem occurred when I tried to test the ".htaccess" by this address: --> "localhost/basic_test/index.php"

It shows an error page with this message:

Oops! This link appears to be broken.

like image 237
Mona Avatar asked Dec 08 '10 19:12

Mona


People also ask

Where is htaccess in Wamp?

There is no . htaccess file that comes with WAMPServer. If you want to use one create it! Edited 1 time(s).

How do I open htaccess file in xampp?

htaccess file is usually present in your C:/xampp/htdocs/wordpress if you are in windows or /opt/lampp/htdocs/wordpress if you are on linux or mac if you can't find it simply... ( for Windows ) enable show hidden files in file manager... (for linux) open terminal and type... and you're ready to go...


2 Answers

Click on Wamp icon and open Apache/httpd.conf and search "#LoadModule rewrite_module modules/mod_rewrite.so". Remove # as below and save it

LoadModule rewrite_module modules/mod_rewrite.so 

and restart all service.

like image 92
Sanjeev Chauhan Avatar answered Oct 02 '22 11:10

Sanjeev Chauhan


RewriteEngine on RewriteBase /basic_test/  RewriteRule ^index.php$ test.php 
like image 31
Pradeep Singh Avatar answered Oct 02 '22 13:10

Pradeep Singh