1
我试图写一个htaccess文件,我无法正常工作。我的网站上有一个名为“gpio”的目录。我正在编写的htaccess文件位于/ var/www/gpio中。.htaccess重写规则不会追加查询字符串的路径
当有人请求URL http://domain.com/gpio时,我希望将请求重定向到脚本,'gpio'附加到查询字符串中。这是我有我的htaccess文件:
# .htaccess
#DirectoryIndex index.html
RewriteEngine on
# I changed domain name a few months ago...
RewriteCond %{HTTP_HOST} ^olddomain.com/*$
RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
# handle the case where the directory exists
RewriteCond %{REQUEST_FILENAME} -d
# this is the part that doesn't work
RewriteRule ^(.*)$ /cgi-bin/pyindex.cgi?q=$1 [L,QSA]
# handle the case where a file is requested
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /cgi-bin/pyindex.cgi?q=$1 [L,QSA]
的问题是,当我访问这个URL,我重定向到脚本,但请求的路径不会被追加到查询字符串。在pyindex.cgi中,当查询字符串被打印时,它只包含'q ='。最终的结果是,当我看到代表帖子类别的页面时,我正在看到我的主页。
任何想什么我做错了,将不胜感激。
谢谢拉维。我把代码放在/var/www/.htaccess中,解决了这个问题。 – Steve