Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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 Twitter访问重写_.htaccess_Mod Rewrite_Twitter_Url Rewriting_Rewrite - Fatal编程技术网

.htaccess Twitter访问重写

.htaccess Twitter访问重写,.htaccess,mod-rewrite,twitter,url-rewriting,rewrite,.htaccess,Mod Rewrite,Twitter,Url Rewriting,Rewrite,我想给用户配置文件URL设置为domain.com/他们的\u用户名 所以我需要所有的字母数字字符,只有少数需要重写 这是我想到的,但它不起作用 RewriteRule ^(\w+)$ test.php?f=first&s=$1 [NC,L] RewriteRule ^((admin|def|images|includes|profile|uploads|users)(.*)) test.php?f=second&s=$2$3 [NC,L] RewriteRule ^p/(.

我想给用户配置文件URL设置为domain.com/他们的\u用户名

所以我需要所有的字母数字字符,只有少数需要重写

这是我想到的,但它不起作用

RewriteRule ^(\w+)$ test.php?f=first&s=$1 [NC,L]

RewriteRule ^((admin|def|images|includes|profile|uploads|users)(.*)) test.php?f=second&s=$2$3 [NC,L]

RewriteRule ^p/(.*)$ index.php?v2=$1 [NC,L]

RewriteRule ^search/((.*)/)?(.*)$ index.php?v=search&v2=$2&s=$3 [NC,L]

RewriteRule ^(faq|privacy|terms|contact|verify)$ index.php?v=$1 [NC,L]

您需要将第一条规则移到底部,否则它将使用
^(\w+)$
模式匹配任何字母数字字符,然后由于
[L]
ast指令而停止处理。正如目前所写,您的另一个规则将永远匹配,因为该模式将匹配“admin”、“search”或“myusername”。“目录”模式已更改为任何非正斜杠的字符匹配,这通常比
通配符更适合URL匹配,因为它可能是贪婪的。我通常也喜欢包含一个
RewriteBase

# Enable mod_rewrite and set the base directory
RewriteEngine on
RewriteBase /

# These are directories (directory/SOMETHING)
RewriteRule ^(admin|def|images|includes|profile|uploads|users)/([^/]*) test.php?f=second&s=$2$3 [NC,L]
# Matches p/SOMETHING
RewriteRule ^p/([^/]*)$ index.php?v2=$1 [NC,L]
# Matches search/SOMETHING/QUERY
RewriteRule ^search/(([^/]*)/)?(.*)$ index.php?v=search&v2=$2&s=$3 [NC,L]
# Matches directory (with or without trailing slash)
RewriteRule ^(faq|privacy|terms|contact|verify)/?$ index.php?v=$1 [NC,L]

# No other rules matched, assume this is a username
RewriteRule ^(\w+)$ test.php?f=first&s=$1 [NC,L]
您可以使用