使用apache和linux ubuntu在本地主机上配置virtualhost和.htaccess
我正试图在ubuntu linux发行版中使用apache服务器在localhost中配置一个网站“redspot.es”。我希望这个网站可以从localhost访问,而不必在浏览器url中他的名字(redspot.es)前写“localhost”字 当我尝试在浏览器中访问redspot.es(在localhost上)时,我得到以下信息:使用apache和linux ubuntu在本地主机上配置virtualhost和.htaccess,apache,.htaccess,ubuntu,localhost,virtualhost,Apache,.htaccess,Ubuntu,Localhost,Virtualhost,我正试图在ubuntu linux发行版中使用apache服务器在localhost中配置一个网站“redspot.es”。我希望这个网站可以从localhost访问,而不必在浏览器url中他的名字(redspot.es)前写“localhost”字 当我尝试在浏览器中访问redspot.es(在localhost上)时,我得到以下信息: Not Found The requested URL / was not found on this server. Apache/2.4.29 (Ubu
Not Found
The requested URL / was not found on this server.
Apache/2.4.29 (Ubuntu) Server at redspot.es Port 80
我正试图找出原因:
我怀疑问题可能出在.htaccess和.conf配置文件中:
我把这个网站放在了/var/www/redspot.es/public_html中
.htaccess文件位于/var/www/redspot.es和/var/www/redspot.es/public_html中:
DirectoryIndex index.php index.html index.htm
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName redspot.es
#remove www de la url, si es que NO (!) es la url ya (^)(empieza por)rinconintangible.es ( y después, como no lleva $(fin), puede llevar cuales quiera cosas)
RewriteEngine On
#RewriteCond %{HTTP_HOST} !^redspot\.es
#RewriteRule (.*) http://redspot.es/$1 [R=301]
# las 2 vlíneas anteriores las ocmento porque ya las hago en el htaccess de un nivel de carpetas superior, es decir, desde la carpeta /public_html/ del server
#remove index.php de la url http://redspot.es/index.php No lo quita de las que no acaban en index.php, ej: index.php?jsdjsdjs=ygg&hsbs=hhh
RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html)\ HTTP
RewriteRule ^(.*)index\.(php|html)$ /$1 [R=301]
在/etc/hosts中,我有:
127.0.0.1 localhost
127.0.1.1 than-pc
192.168.1.137 redspot.es
解决了。似乎有必要将网站文件夹放入
/var/www/html
文件夹(/var/www/html/redspot.es/public_html/)中
/etc/apache2/sites-enabled$ sudo a2ensite redspot.es
127.0.0.1 localhost
127.0.1.1 than-pc
192.168.1.137 redspot.es