Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用apache和linux ubuntu在本地主机上配置virtualhost和.htaccess_Apache_.htaccess_Ubuntu_Localhost_Virtualhost - Fatal编程技术网

使用apache和linux ubuntu在本地主机上配置virtualhost和.htaccess

使用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

我正试图在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 (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