不能得到的.htaccess localhost上工作 [英] Can't get .htaccess to work on localhost
问题描述
我想获得的mod_rewrite使用我的本地服务器上的.htaccess文件工作。
I am trying to get mod_rewrite to work by using a .htaccess file on my localhost server.
我的apache2.conf文件包含:
My apache2.conf file contains:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
和
Include mods-enabled/*.load
/etc/apache2/mods-enabled/rewrite.load文件包含:
/etc/apache2/mods-enabled/rewrite.load file contains:
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
的.so文件存在。
The .so file exists.
服务的Apache2重启
不显示警告/错误
我的.htaccess包含:
My .htaccess contains:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*)$ /process.php?path=$1 [NC,L,QSA]
和它位于 /无功/网络/ WP /可湿性粉剂内容/插件/为myplugin /
process.php包含的print_r($ _ SERVER);
process.php contains print_r($_SERVER);
我访问的http://本地主机/ WP /可湿性粉剂内容/插件/为myplugin / randomstring 并始终得到一个404错误。
I am visiting http://localhost/wp/wp-content/plugins/myplugin/randomstring and always getting a 404 error.
我试图改变.htaccess文件到一个随机字符串试图触发一个500错误,以确保的.htaccess正在执行(?),但仍然得到一个未找到404错误。
I tried changing the .htaccess file to a random string trying to trigger a 500 error to make sure the .htaccess was being "executed"(?), but still getting a 404 not found error.
的var_dump(in_array('mod_rewrite的',apache_get_modules()));
则返回true
我在做什么错了?这始终工作在我的在线服务器。
what am i doing wrong? This always works on my online servers.
推荐答案
检查模块使用php_info启用()。如果有一些错误。
Check if the module is enabled using php_info(). If there is some errors.
试试下面的命令。
sudo a2enmod rewrite
如果你改变(在/ etc / apache2的/网站的可用/默认)的AllowOverride无
到的AllowOverride全部
那么它会工作。
I think if you change (/etc/apache2/sites-available/default) AllowOverride none
to AllowOverride All
then it will work.
如果你仍然越来越错误,然后做提到的步骤的>。
If still you are getting the error, then do the steps mentioned here.
该教程是有点老了,但你可以得到模块的工作。
The tutorial is bit old, but you can get the module working.
我希望这有助于。
这篇关于不能得到的.htaccess localhost上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!