使用xampp的system32中的.htaccess和主机URL " i create "问题



我在URL的方向上遇到问题。。

我在examplep 中创建新的URL

pro_mvc.com

我想写。htaccess这个代码

<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteBase /mvc_pro/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule  ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>

我的htdocs中的mvc_pro中有public是

C:xampphtdocsmvc_propublic

我在中创建了我的mvc_pro.com,而不是localhost

C:WindowsSystem32driversetchosts

使用此代码

127.0.0.1 mvc_pro.com

在apache中,代码在中

C:xamppapacheconfextrahttpd-vhosts.conf

<VirtualHost *:80>
DocumentRoot "C:xampphtdocsmvc_pro"
ServerName mvc_pro.com
</VirtualHost>

如果我想在mvc_pro.com/public/qwjleqweukwe之后写任何东西,他不会把我转到index.php"我的路径中有这个文件"他为什么告诉我

Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
mvc_pro.com
Apache/2.4.34 (Win32) OpenSSL/1.1.0i PHP/7.2.10

再次感谢!

AllowOverride指令用于允许在web服务器中使用.htaccess,以允许重写Apache配置。

  1. 确保在httpd.conf中启用了mod_rewrite。对于XAMPP,应启用默认情况下
  2. 在文档根目录的httpd-vhosts.conf中设置AllowOverride All
  3. 确保重新启动Apache

您的VirtualHost配置应该如下所示:

<VirtualHost *:80>
DocumentRoot "C:xampphtdocsmvc_pro"
ServerName mvc_pro.com
<Directory C:xampphtdocsmvc_pro>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

in:

<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteBase /mvc_pro/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule  ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>

只需删除

RewriteBase /mvc_pro/public

相关内容

最新更新