使用.htaccess和localhost url进行路由的问题

时间:2018-06-10 14:03:17

标签: php .htaccess localhost wamp

我正在尝试使用mod_rewrite for Apache将流量从我的delopment url路由到我的MCV控制器。但我不断收到“内部服务器错误”

方面: Windows 10,WAMP

Localhost网址:taskmanager.local

.htaccess文件:

type User @model {
   id: ID! @isUnique
   position: Position
}
type Position {
  lat: Int
  lng: Int 
}

虚拟主机:

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

1 个答案:

答案 0 :(得分:0)

好的,所以经过一些随机的摸索后我解决了这个问题。我对.htaccess文件和httpd-vhost.conf文件以及所有内容进行了一些更改,现在localhost网址指向了/public文件夹。

.htaccess文件:

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

更改 taskcomplete.local/public =&gt; /public

虚拟主机:

# TaskComplete
<VirtualHost *:80>
  DocumentRoot "D:\Dropbox\web\projects\php\task_complete"
  ServerName taskcomplete.local
  <Directory "D:\Dropbox\web\projects\php\task_complete">
    Options Indexes FollowSymLinks ExecCGI Includes
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

更改 D:\Dropbox\web\projects\php\task_complete =&gt; D:\Dropbox\web\projects\php\task_complete\public