htaccess用子文件夹中的参数重写重定向 [英] htaccess rewrite redirect with parameters in subfolder

查看:94
本文介绍了htaccess用子文件夹中的参数重写重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您转到url时,我希望这样做: http://www.example.com/subdir/paramvalue

I want that when you go to url: http://www.example.com/subdir/paramvalue

重定向到

http://www.example.com/subdir/index.php ?param = paramvalue

我的.htaccess文件是:

My .htaccess file is:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^subdir/(.*)   subdir/index.php?param=$1 [L,QSA]

但是不起作用.我该怎么办?

But does not work. How can i do ?

推荐答案

将此规则放在subdir/.htaccess(不是网站根目录)中:

Place this rule in subdir/.htaccess (not site root):

RewriteEngine On
RewriteBase /subdir/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ index.php?param=$0 [L,QSA]

这篇关于htaccess用子文件夹中的参数重写重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆