[英]How to enable htaccess on localhost
I'm running my website on my local server and using mamp on my mac machine. 我在本地服务器上运行我的网站,并在mac机上使用mamp。
Was just wondering what do i have to do to allow the url redirections on my htaccess file to be read on my local server as per how it works on my live site. 只是想知道我该怎么做才能允许htaccess文件上的URL重定向根据其在我的实时站点上的工作方式在本地服务器上读取。
I managed to move my .htaccess file into my local host root which is: /Applications/MAMP/htdocs. 我设法将.htaccess文件移动到我的本地主机根目录下:/ Applications / MAMP / htdocs。
But when i try running: localhost:8888/products, i get a no found error. 但是,当我尝试运行:localhost:8888 / products时,出现未找到的错误。
RewriteEngine on
##RewriteCond %{HTTP_HOST} ^everything-under.sg$ [NC]
RewriteRule ^(.*)$ http://www.everything-under.sg/$1 [L,R=301]
RewriteRule ^products?$ pages/list.php [NC,L]
...
I was just wondering if i'm missing something that results in the .htaccess not being detected and working. 我只是想知道我是否丢失了导致无法检测到.htaccess并正常工作的内容。 Any help greatly appreciated. 任何帮助,不胜感激。
I've tried a fresh installation of MAMP 3.0.7 and the .htaccess and the mod_rewrite module is enabled on default on /Applications/MAMP/htdocs 我尝试过全新安装MAMP 3.0.7和.htaccess,并且默认情况下在/ Applications / MAMP / htdocs中启用了mod_rewrite模块
In any case, you should be checking if the following lines are in your "/Applications/MAMP/conf/apache/httpd.conf" file. 无论如何,您应该检查“ /Applications/MAMP/conf/apache/httpd.conf”文件中是否包含以下行。 First make sure the mod_rewrite module is uncommented. 首先,确保mod_rewrite模块未注释。
LoadModule rewrite_module modules/mod_rewrite.so
The "AllowOveride All" allows the use of the .htaccess file in the httpd config file. “ AllowOveride All”允许在httpd配置文件中使用.htaccess文件。
<Directory "/Applications/MAMP/htdocs">
# .....
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#.....
</Directory>
According to your current mod_rewrite rules, localhost:8888/products would be 301 redirected to http://www.everything-under.sg/products . 根据您当前的mod_rewrite规则,localhost:8888 / products将被重定向到http://www.everything-under.sg/products 。 Is that the intention? 那是意图吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.