.htaccess mode rewrite engine seems not working in my local marchine

两盒软妹~` 提交于 2019-12-11 18:31:49

问题


I have urls like this http://localhost/mysite/index.php?page=something which I only want to be http://localhost/mysite/something and on the homepage it should be http://localhost/mysite/ not http://localhost/mysite/index.php by using .htaccess

Below is my code in .htaccess file:

<IfModule mod_rewrite.c>
    RewriteEngine On
    rewriterule ^([^-]+)$ index.php?page=$1[L]
</IfModule>

But it shows the same to what has been before. I don't know if I wrote something wrong to the code above or maybe my apache does not support it because I never knew it before.

Could someone help me to solve this?


回答1:


Please see the documentation on rewrite logging and provide the output here so we may better assist you.




回答2:


If <IfModule mod_rewrite.c> is failing, then you don't have the rewrite module compiled in apache, or it isn't loaded. Do you have this somewhere in your config?

LoadModule rewrite_module modules/mod_rewrite.so

(or if there is a conditional <IfDefine> around it, make sure the define is satisfied)



来源:https://stackoverflow.com/questions/11484853/htaccess-mode-rewrite-engine-seems-not-working-in-my-local-marchine

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