问题
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