我正在尝试设置重写规则,以便localhost / test / {this}之后的任何内容都转发到localhost / test / index.php?{here}
我可以访问服务器,配置目前如下所示:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /var/www/test/>
AllowOverride All
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ index.php?$1
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
但是目前,在访问localhost / test / something时,它显示了localhost / index.php而不是显示/localhost/test/index.php?some,所以它会重写到错误的地方..任何想法?感谢
答案 0 :(得分:0)
在/ var / www / test
中创建.htaccess文件RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
答案 1 :(得分:0)
已解决..我发现只要我将AllowOverride All重定向到/index.php,然后发现我在之前的测试中留下了一个.htaccess文件,这些文件搞砸了。删除,更新我的规则,现在正在工作。谢谢你的帮助!