Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.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 mod_rewrite:为什么它在本地工作而不是在线?_.htaccess_Mod Rewrite_Friendly Url - Fatal编程技术网

.htaccess mod_rewrite:为什么它在本地工作而不是在线?

.htaccess mod_rewrite:为什么它在本地工作而不是在线?,.htaccess,mod-rewrite,friendly-url,.htaccess,Mod Rewrite,Friendly Url,我正在本地开发一个应用程序(域名为.dev) 为了使用友好的URL,我将.htaccess设置为: RewriteEngine on # Externally redirect to add missing trailing slash RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://example.com/$1/?%{QUERY_STRING}[NC,R,L] RewriteRule ^about/$ about.php [NC,L]

我正在本地开发一个应用程序(域名为.dev)

为了使用友好的URL,我将.htaccess设置为:

RewriteEngine on
# Externally redirect to add missing trailing slash
RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://example.com/$1/?%{QUERY_STRING}[NC,R,L]
RewriteRule ^about/$ about.php [NC,L]
RewriteRule ^issues/$ issues.php [NC,L]
RewriteRule ^issue/([a-z0-9_\-]+)/$ issue.php?slug=$1 [NC,L]

SetEnv PHP_VER 5
IndexIgnore *
Options +FollowSymLinks
它很好用。令人烦恼的是,当上网时,它并不那么好:

不返回GET变量。为什么?我看不出来

RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://mydomain.eu/$1/?%{QUERY_STRING}[NC,R,L]

应该匹配该URL,但这是唯一一个使用[R]标志进行外部重定向的URL。尝试注释这一行,以确保应用程序中没有其他部分执行重定向。我的猜测是有。

根据过去的经验,我的猜测是重写基础,可能是因为您的服务器是共享的,或者是其他一些非标准配置

RewriteEngine on

#Set base as doc root.
RewriteBase /

# Externally redirect to add missing trailing slash
RewriteRule ^(([a-z0-9._\-]+/)*[a-z0-9_\-]+)$ http://mydomain.eu/$1/?%{QUERY_STRING}[NC,R,L]
RewriteRule ^about/$ about.php [NC,L]
RewriteRule ^issues/$ issues.php [NC,L]
RewriteRule ^issue/([a-z0-9_\-]+)/$ issue.php?slug=$1 [NC,L]

SetEnv PHP_VER 5
IndexIgnore *
Options +FollowSymLinks

替换URL和标志之间缺少一些空格。您还可以将第一条规则简化如下:

RewriteRule ^([a-z0-9._-]+/)*[a-z0-9_-]+$ %{REQUEST_URI}/ [NC,R=301,L]

正确的重定向目标是什么?