当你去网址时,我想要这样: http://www.example.com/subdir/paramvalue
重定向到
http://www.example.com/subdir/index.php?param=paramvalue
我的.htaccess文件是:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^subdir/(.*) subdir/index.php?param=$1 [L,QSA]
但是不起作用。我该怎么办?
答案 0 :(得分:1)
将此规则放在RewriteEngine On
RewriteBase /subdir/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ index.php?param=$1 [L,QSA]
(不是网站根目录)中:
topics_dict = { "title":[],\
"score":[],\
"id":[], "url":[],\ -> Error
"comms_num": [],\
"created": [],\
"body":[]}
答案 1 :(得分:0)
谢谢anubhava! 首先我从/ etc / apache2 / sites-available /编辑000-default,然后添加:
<Directory "/var/www">
AllowOverride All
</Directory>
然后.htaccess中的解决方案是:
RewriteEngine On
RewriteBase /subdir/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?param=$1 [QSA,L]
最后在/subdir/index.php
我得到的值为paramvalue:
$myParamValue = $_GET["param"];
echo myParamValue
它返回: paramvalue