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 URL重写引擎内部服务器错误_.htaccess - Fatal编程技术网

.htaccess URL重写引擎内部服务器错误

.htaccess URL重写引擎内部服务器错误,.htaccess,.htaccess,我正在使用.htaccess中的以下配置尝试重写表单http://www.mysite.com/subdir/page.php?param=4至http://www.mysite.com/subdir/page/param/4: # Turn on the rewrite engine Options +FollowSymlinks RewriteEngine on # Request routing RewriteRule ^([a-zA-Z_-]*)$ index.php?name=$

我正在使用
.htaccess
中的以下配置尝试重写表单
http://www.mysite.com/subdir/page.php?param=4
http://www.mysite.com/subdir/page/param/4

# Turn on the rewrite engine
Options +FollowSymlinks
RewriteEngine on

# Request routing
RewriteRule ^([a-zA-Z_-]*)$   index.php?name=$1 [nc,qsa]
但是,当我访问该页面时,会出现一个内部服务器错误。配置有问题吗

编辑:我已将其更新为以下内容,但现在它似乎没有进行任何重写,当我尝试使用类似
的URL时,它会给我一个404http://www.mysite.com/subdir/param/2

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^name=([0-9]+)$ [NC]
RewriteRule ^project-testing/ws/index.php$ /project-testing/ws/name/%1 [R=301,NC,L]

您需要使用
%{QUERY\u STRING}
读取URL的查询字符串,以便根据该字符串重定向

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteCond %{QUERY_STRING} ^param=([0-9]+)$ [NC]
RewriteRule ^subdir/page.php$ subdir/page/param/%1 [R=301,NC,L]
或者,如果您希望访问:

http://www.mysite.com/subdir/page/param/4
显示以下内容:

http://www.mysite.com/subdir/page.php?param=4
那就是这样,

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteBase /

RewriteRule ^subdir/page/([^/]+)/([^/]+)$ subdir/page.php?$1=$2 [NC,L]

您请求的url是什么?我使用了以下代码(根据您在这里编写的内容修改为我的实际url):选项+FollowSymLinks-多视图
RewriteEngine on RewriteBase/RewriteCond%{QUERY_STRING}^name=([0-9]+)$[NC]RewriteRule^项目测试/ws/index.php$/project测试/ws/name/%1[R=301,NC,L]
但它不起作用。它只是说“找不到页面”,就好像没有进行重写一样。@rar@rar是一个数字,也可以是一个字符串。您试图访问哪个URL,结果是404?你在问题上提到的第一个?如果您想访问
http://www.mysite.com/subdir/page/param/4
你必须使用我在回答中给你的第二个例子,仔细阅读:)
name
可以是字符串(在这个例子中,唯一可用的数据意味着它将是字符串),重写的URL就是我试图访问的URL。所以
http://www.mysite.com/subdir/page/param/4
@rar仅使用第二条规则,即我在答案上发布的规则。