.htaccess doesn't work in WampServer 2.5

2019-09-09 09:20发布

问题:

I have got a problem with .htaccess in WampServer 2.5.

I use Windows 10 Enterprise and have installed wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-64b_August_2015 on it.

Every thing is going well except .htaccess configs. I want .php extention removed from website url like (www.mywebsite.com/contact.php) should look like (www.mywebsite.com/contact), but it doesn't work and displays (404 Not Found error).

The URLs link is like:

<a href="contact">link</a>

But when adding .php extention at the link :

<a href="contact.php">link</a>

it works.

I use this bunch of codes in my .htaccess :

<IfModule mod_rewrite.c>
    Options +FollowSymlinks
  # Options +SymLinksIfOwnerMatch
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME}\.php -f 
    RewriteRule ^(.*)$ $1.php
  # RewriteBase /
</IfModule>

I also tried some other codes like above, but no results. Previously in windows 8.1 and wampserver2.2 it was waroking, but now in wamp2.5 it puts me in trouble. how should i get it solved?

回答1:

check this youtube step by step tutorial related to enable rewrite module in wamp apache https://youtu.be/xIspOX9FuVU?t=1m43s Wamp server icon -> Apache -> Apache Modules and check the rewrite module option



回答2:

The first thing to remember is correctly coded .htaccess files work just fine.

The first thing to check is that you have enabled the rewrite_module in Apache. Without this module activated .htaccess files are ignored.

To check and enable this module use the WAMPManager menu like so:

wampmanager -> Apache -> Module

This should show you a menu with all the available apache modules, there are many you will have to scroll the menu down to rewrite_module, if there is a TICK beside this module it is enabled already, if there is no TICK, then click on the rewrite_module menu item and it will amend the httpd.conf file automatically and restart Apache for you.

Then try you site again.