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
Apache 简单。htaccess赢了';I don’我不会重写,而且似乎一点也不匹配_Apache_.htaccess_Mod Rewrite_Redirect_Rewrite - Fatal编程技术网

Apache 简单。htaccess赢了';I don’我不会重写,而且似乎一点也不匹配

Apache 简单。htaccess赢了';I don’我不会重写,而且似乎一点也不匹配,apache,.htaccess,mod-rewrite,redirect,rewrite,Apache,.htaccess,Mod Rewrite,Redirect,Rewrite,应该是直截了当的。不重定向到。它只是尝试加载/denver cars/而denver cars位于URL中。我是不是遗漏了什么?我试过在规则列表中上下移动它,也试过各种各样的旗帜,但都没有用。有谁能解释一下我的3小时问题需要10秒才能解决 Options +FollowSymlinks RewriteEngine on RewriteBase / # Force www RewriteCond %{HTTP_HOST} ^site.com [NC] RewriteRule ^(.*)$ htt

应该是直截了当的。不重定向到。它只是尝试加载/denver cars/而denver cars位于URL中。我是不是遗漏了什么?我试过在规则列表中上下移动它,也试过各种各样的旗帜,但都没有用。有谁能解释一下我的3小时问题需要10秒才能解决

Options +FollowSymlinks
RewriteEngine on
RewriteBase /

# Force www
RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301,NC]

# Redirect google index dir's to new dir
RewriteRule ^/(.*)-cars/ /newcars-in-$1/  [NC,R=301,L]

# Disable rewrite for Folder Names
RewriteCond %{REQUEST_FILENAME} [NC,OR]
RewriteCond %{REQUEST_FILENAME} [NC,OR]
RewriteCond %{REQUEST_URI} ^awstats
RewriteRule .* - [L]

# Permit pretty URL directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . / [L]

## Allow image hotlinks from my domains
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com?.*$
RewriteRule .*\.jpg$      -        [F,L]

正则表达式中有一个前导斜杠。用于匹配htaccess文件中规则的URL的前导斜杠已删除,因此
^/(.*)
将永远不会匹配任何内容。你想要:

RewriteRule ^(.*)-cars/ /newcars-in-$1/  [NC,R=301,L]

谢谢你,乔恩。你是对的,但这并不能解决问题。我更新了它,它仍然以同样的方式运行。(我已经清除了缓存,甚至更改了URL,但行为还是一样的)