Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Php 将对alias的所有调用重定向到同一alias的子文件夹中的一页_Php_.htaccess_Url Rewriting_Wamp_Http Redirect - Fatal编程技术网

Php 将对alias的所有调用重定向到同一alias的子文件夹中的一页

Php 将对alias的所有调用重定向到同一alias的子文件夹中的一页,php,.htaccess,url-rewriting,wamp,http-redirect,Php,.htaccess,Url Rewriting,Wamp,Http Redirect,我在wamp服务器上创建htaccess文件时遇到问题。 我想将对localhost服务器上别名(虚拟文件夹)的所有调用重定向到同一别名上的公用文件夹。 例如,我想 http://localhost/test/***/ or http://localhost/test/***/***/***/ 重定向到 http://localhost/test/public/indes.php?a=******. 我发现了很多例子,但没有一个不能正常工作,我得到一个错误“页面没有正确重定向”或“500内部

我在wamp服务器上创建htaccess文件时遇到问题。
我想将对localhost服务器上别名(虚拟文件夹)的所有调用重定向到同一别名上的公用文件夹。 例如,我想

http://localhost/test/***/ or http://localhost/test/***/***/***/
重定向到

http://localhost/test/public/indes.php?a=******.
我发现了很多例子,但没有一个不能正常工作,我得到一个错误“页面没有正确重定向”或“500内部服务器错误”

这是我的htaccess示例文件:

RewriteEngine on
RewriteBase /test
RewriteRule ^(.*)$ http://localhost/test/public/index.php [R=301,L]
有人能告诉我哪里错了吗?
提前感谢您的回复。

我将尝试一下:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /test/public/index.php

同样,Firefox中的“页面未正确重定向”或Chrome中的“此网页有重定向循环”。非常感谢@Santy,你救了我!我只想补充一件事来完成答案。我没有使用最后一行RewriteRule^(.*)$/test/public/index.php,而是使用RewriteRule^(.*)$/test/public/index.php?a=$1。谢谢!是的,你可以,但是你也可以用它来创建“友好的url”,比如yourdomain.com/account/manager/,并获取$\u SERVER['REQUEST\u URI']和$\u SERVER['SCRIPT\u NAME']中的url,而不是yourdomain.com/?action=account§ion=manager。。。等