.htaccess匹配任何内容并发送到PHP文件

.htaccess匹配任何内容并发送到PHP文件,php,.htaccess,Php,.htaccess,我的正则表达式尝试匹配所有结果并重定向到页面。我想将请求的地址发送到页面: RewriteRule ^/[\w\W]*$ processor.php [R,NC,L] 例如,我的地址是: www.mywebsite.com/mySecretCode123 我希望我的php文件能够读取它: 我如何才能做到这一点?.htaccees # RewriteCond is condition - make rewrite only if file doesn't exists # (.+) mea

我的正则表达式尝试匹配所有结果并重定向到页面。我想将请求的地址发送到页面:

RewriteRule ^/[\w\W]*$ processor.php [R,NC,L]
例如,我的地址是:

www.mywebsite.com/mySecretCode123
我希望我的php文件能够读取它:


我如何才能做到这一点?

.htaccees

# RewriteCond is condition - make rewrite only if file doesn't exists
# (.+) means "any character, one or more"
RewriteCond  %{REQUEST_FILENAME} !-f 
RewriteRule ^(.+)$ processor.php?mySecretCode=$1 
PHP


通过
httpd.conf
启用mod_rewrite和.htaccess,然后将此代码放入
文档根目录下的
.htaccess

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# If the request is not for a valid link
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ processor.php?$1=$1 [L,QSA]

我正在使用
RewriteRule^/[\w\w]*$processor.php?key=$1[R,NC,L]
而不是
(*)
,因为我认为它可能更快。你认为这是真的吗?@user1477388我不确定,但我认为是相同的还是更快的。但是你应该更关注php、db的速度,而不是mod_的重写速度。谢谢你的详细回答。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# If the request is not for a valid directory
RewriteCond %{REQUEST_FILENAME} !-d
# If the request is not for a valid file
RewriteCond %{REQUEST_FILENAME} !-f
# If the request is not for a valid link
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.+)$ processor.php?$1=$1 [L,QSA]