Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.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
Regex 子文件夹索引的重写规则_Regex_Apache_.htaccess_Security_Mod Rewrite - Fatal编程技术网

Regex 子文件夹索引的重写规则

Regex 子文件夹索引的重写规则,regex,apache,.htaccess,security,mod-rewrite,Regex,Apache,.htaccess,Security,Mod Rewrite,我有这个网址 http://myurl.com/shiftturn/index.php?m=value 我想: http://myurl.com/shiftturn/value 这是我的.htaccess RewriteEngine On RewriteRule /shiftturn/([^/]*)$ /index.php?m=$1 [L] 但是不起作用。 如何使用正确的htaccess表达式获取所需的url类型?将此规则放入/shiftturn/.htaccess: RewriteEng

我有这个网址

http://myurl.com/shiftturn/index.php?m=value
我想:

http://myurl.com/shiftturn/value
这是我的.htaccess

RewriteEngine On
RewriteRule /shiftturn/([^/]*)$ /index.php?m=$1 [L]
但是不起作用。
如何使用正确的htaccess表达式获取所需的url类型?

将此规则放入
/shiftturn/.htaccess

RewriteEngine On
RewriteBase /shiftturn/

RewriteCond %{THE_REQUEST} /index\.php\?m=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L,NE]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ index.php?m=$1 [L,QSA]

你看到了什么原始URL?谢谢@zx81,你的正则表达式回答已经告诉我你可以很好地处理这些重写fu,谢谢你anubhava。。。但是你重写的答案远不止正则表达式!您精通Apache语法的详细信息。我也没有一个好的方法来测试重写。例如,我不想将文件上传到web服务器。我见过几位在线重写测试人员,但他们并没有真正尝试过。这是我目前无法回答重写问题的两个原因。实际上,所有这些在线测试人员都是无用的。我只需要在我的笔记本电脑上运行一个普通的Apache服务器来测试这些规则。