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
Php htaccess重写字母和数字符号_Php_Regex_.htaccess - Fatal编程技术网

Php htaccess重写字母和数字符号

Php htaccess重写字母和数字符号,php,regex,.htaccess,Php,Regex,.htaccess,我想传递url参数,如example.com/username或example.com/myemail@gmail.com如果有人从表中选择,我想匹配两个条件? 这是我的.htaccess代码 # Default index page DirectoryIndex index.php # Remove file extensions RewriteCond %{REQUEST_FILENAME} !-f RewriteEngine on RewriteCond %{REQUES

我想传递url参数,如
example.com/username
example.com/myemail@gmail.com
如果有人从表中选择,我想匹配两个条件? 这是我的.htaccess代码

 # Default index page
 DirectoryIndex index.php


 # Remove file extensions
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteEngine on

 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME}\.php -f
 RewriteRule ^(.*)$ $1.php

 # Display a custom error message
 #ErrorDocument 404 http://localhost//
 #ErrorDocument 500 http://localhost//

 #ErrorDocument 404  404
 #ErrorDocument 500  500
 #Profile rewrite
 RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?ref=$1

你现在有什么错误吗?你的问题完全不清楚。哪两个条件?在重写上下文中,“从表中选择”是什么意思?为什么首先
RewriteCond
,然后
RewriteEngine on
?如果我理解您的意图,您可能还想查看一下,您可以从example.com/abc first/abc.php和/index.php中获得。然而,example.com/abc@def.gh将被重新连接到/abc@def.gh.php,因为第二条规则只接受字母、数字、下划线和连字符。