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 使用查询处理重定向404 URL_.htaccess_Http Status Code 404 - Fatal编程技术网

.htaccess 使用查询处理重定向404 URL

.htaccess 使用查询处理重定向404 URL,.htaccess,http-status-code-404,.htaccess,Http Status Code 404,所有使用site.com/p/QUERY的查询都会得到处理,但一些用户错误地使用site.com/QUERY进行请求,他们会看到404错误页面 如何将site.com/QUERY重定向到site.com/p/QUERY,并通过.htaccess避免404错误 在htaccess教程和问题中找不到此案例的任何解决方案。使用此选项 <Files index.php> order allow,deny deny from all </Files> # Turn on URL r

所有使用
site.com/p/QUERY
的查询都会得到处理,但一些用户错误地使用
site.com/QUERY
进行请求,他们会看到404错误页面

如何将
site.com/QUERY
重定向到
site.com/p/QUERY
,并通过.htaccess避免404错误

在htaccess教程和问题中找不到此案例的任何解决方案。

使用此选项

<Files index.php>
order allow,deny
deny from all
</Files>
# Turn on URL rewriting
RewriteEngine On
Options +FollowSymLinks
# Installation directory
RewriteBase /
# Allow these directories and files to be displayed directly:
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico|img|js|css|media)
# Rewrite all other URLs to /p/URL
RewriteRule ^([^/]+)$ /p/$1  [PT,L]
# Rewrite all other URLs to /p/URL or /p/some.html?var=1&var2=2
RewriteRule ^(.*)$ /p/$1  [PT,L]

命令允许,拒绝
全盘否定
#启用URL重写
重新启动发动机
选项+FollowSymLinks
#安装目录
重写基/
#允许直接显示以下目录和文件:
1美元^(索引\.php | robots\.txt | favicon\.ico | img | js | css | media)
#将所有其他URL重写为/p/URL
重写规则^([^/]+)$/p/$1[PT,L]
#将所有其他URL重写为/p/URL或/p/some.html?var=1&var2=2
重写规则^(.*)$/p/$1[PT,L]

index.php、login.php等需要一些例外。只需要重定向查询。你的意思是只获取查询?类似于
site.com/p/?a=b
而不是
site.com/p/a/b
?请按您的Database@h2ooooooo查询有时直接通过url插入。像这样:
site.com/q/TYPED-IN-HERE
-@luther:要测试它。。谢谢