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 htaccess重写和重定向_.htaccess_Mod Rewrite - Fatal编程技术网

.htaccess htaccess重写和重定向

.htaccess htaccess重写和重定向,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,我开发了一个新网站,但我想保留一些已经在谷歌上索引的页面地址。 谷歌以这种方式编制了索引: mysite.com/test-page/(末尾带斜杠) 我在htaccess上添加了以下条件,以在浏览时切断php扩展: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php 从页面重写rule-off.php扩展名:

我开发了一个新网站,但我想保留一些已经在谷歌上索引的页面地址。 谷歌以这种方式编制了索引: mysite.com/test-page/(末尾带斜杠)

我在htaccess上添加了以下条件,以在浏览时切断php扩展:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
从页面重写rule-off.php扩展名:

mysite.com/test-page
为此,我无法从谷歌url访问页面

存在添加重定向的方法 发件人:mysite.com/test-page/ 收件人:mysite.com/test-page ?


这将在传入的请求中看到斜杠,但不会将其传递给结果文件名。

这个问题似乎与主题无关,因为它涉及的更多是作为网站管理员维护网站,而不是编程。您可能可以在webmasters.stackexchange.com上找到答案(这里经常出现)。
RewriteRule ^(.*)/?$ $1.php [L,NC]