简体   繁体   English

本地主机.htaccess文档根

[英]localhost .htaccess document root

I have an htaccess file with a simple rewrite rule. 我有一个带有简单重写规则的htaccess文件。

RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)/?$ index.php?page=$1

On my web server, the index.php file is in /var/www, and it works normally. 在我的Web服务器上,index.php文件位于/ var / www中,并且可以正常工作。

On my local host, the index.php fle is in /var/www/projects/porto and while the file runs normally, no linked content ( images, css, etc ) is loaded. 在我的本地主机上,index.php文件位于/ var / www / projects / porto中,并且在文件正常运行时,未加载任何链接内容(图像,css等)。

I am totally new to htaccess files. 我对htaccess文件完全陌生。 Any ideas on how to work around it so I can do my testing in my locan environment? 关于如何解决它的任何想法,以便我可以在我的疯子环境中进行测试?

All I've tried is changing my .htaccess file to 我所尝试的只是将.htaccess文件更改为

RewriteEngine On
RewriteRule ^([a-zA-Z0-9]+)/?$ /running/Porto/index.php?page=$1

But no luck. 但是没有运气。

Okay, so continuing our discussion on setting up a VirtualHost on your local machine/environment, it is roughly the same as on your other server. 好的,因此继续我们关于在本地计算机/环境上设置VirtualHost的讨论,它与在其他服务器上大致相同。 If you can copy the Apache configuration file from the web server then that will be a good start. 如果可以从Web服务器复制Apache配置文件,那么这将是一个不错的开始。 At a minimum you will need something like this: 至少您需要这样的东西:

<VirtualHost *:80>
    ServerName localdevsite.com
    DocumentRoot /var/www/running/Proto
</VirtualHost>

(This assumes that somewhere in the file you have NameVirtualHost *:80 ) (这假设您在文件中的某个位置具有NameVirtualHost *:80

The one additional thing you will need to do in your local environment is add a hosts entry: 您需要在本地环境中做的另一件事是添加主机条目:

In Linux you usually do this in /etc/hosts with something like: 在Linux中,通常在/ etc / hosts中执行以下操作:

127.0.0.1 localdevsite.com 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM