Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
HTACCESS:在regex的帮助下替换URL_Regex_.htaccess - Fatal编程技术网

HTACCESS:在regex的帮助下替换URL

HTACCESS:在regex的帮助下替换URL,regex,.htaccess,Regex,.htaccess,我有这个网址 http://localhost:8888/dochealth/child-doc?cat=doctor 并希望用.htaccess REGEX替换它,使其成为 http://localhost:8888/dochealth/child-doc/doctor 到目前为止,我已经尝试了这个正则表达式,但它不起作用 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d

我有这个网址

http://localhost:8888/dochealth/child-doc?cat=doctor
并希望用.htaccess REGEX替换它,使其成为

http://localhost:8888/dochealth/child-doc/doctor
到目前为止,我已经尝试了这个正则表达式,但它不起作用

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
RewriteRule ^child-doc/([0-9a-zA-Z_-]+) child-doc?cat=$1 [NC,L]
</IfModule>

重新启动发动机
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}\.php-f
重写规则^(.*)$$1.php[NC,L]
重写规则^child doc/([0-9a-zA-Z_u-])子文档?cat=$1[NC,L]
这样做:

选项-多视图
重新启动发动机
重写规则^child doc/([\w-]+)child doc.php?cat=$1[NC,QSA,L]
重写cond%{REQUEST_FILENAME}-D
RewriteCond%{REQUEST_FILENAME}.php-f
重写规则^(+?)/?$$1.php[L]
变化如下:

  • .php
    扩展处理程序规则移到底部
  • 在其他规则中使用
    child doc.php
  • 同一规则中附加的
    QSA
    (查询字符串追加)
  • 关闭
    MultiViews
    以禁用Apache的内容协商服务