我已经在我的系统上安装了WAMPSERVER。在htdocs文件夹中,我有我的项目文件夹,名为"在线商店"
所以为了访问我的项目,我写
http://localhost/online-store
我想要所有请求,例如
http://locahost/online-store/products/2 or http://localhost/online-store/products/
重定向到 API.php。我已经为此编写了htaccess代码,但它说
/online-store/products url was not found on the system.
我正在重写htaccess以使其成为一个宁静的API。下面是我的HTACCESS代码。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)$ api.php?request=$1 [QSA,NC,L]
</IfModule>
确保将此代码放在htdocs/online-store/.htaccess
中:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /online-store/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ api.php?request=$1 [QSA,L]
</IfModule>
您需要
更改 httpd.conf 中的代码
wampdir/bin/apache/apache2.x.x./conf/httpd.conf
<FilesMatch "^'.ht">
Order allow,deny
Allow from all
Satisfy All
</FilesMatch>