.htaccess doesn't work in WampServer 2.5

让人想犯罪 __ 提交于 2019-12-12 02:46:06

问题


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.



来源:https://stackoverflow.com/questions/33231857/htaccess-doesnt-work-in-wampserver-2-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!