Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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_Url_Mod Rewrite_Url Rewriting - Fatal编程技术网

.htaccess 在htaccess中重写而不隐藏文件名

.htaccess 在htaccess中重写而不隐藏文件名,.htaccess,url,mod-rewrite,url-rewriting,.htaccess,Url,Mod Rewrite,Url Rewriting,我有一个网站,我正在重写URL以使用文件package.php,但URLhttp://example.com/package-type/airport/hotel-name。它在翻页时工作正常。然而,谷歌网站管理员工具正在报告URL的错误http://example.com/package.php?/package-类型/机场/酒店名称。为什么我的htaccess重写不能为谷歌工作?以下是我在htaccess文件中的重写代码: #Redirects hotel pages to package.

我有一个网站,我正在重写URL以使用文件
package.php
,但URL
http://example.com/package-type/airport/hotel-name
。它在翻页时工作正常。然而,谷歌网站管理员工具正在报告URL的错误
http://example.com/package.php?/package-类型/机场/酒店名称
。为什么我的htaccess重写不能为谷歌工作?以下是我在htaccess文件中的重写代码:

#Redirects hotel pages to package.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /package.php?/$1 [L]

# Removes package.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} ^GET.*package\.php [NC]
RewriteCond %{REQUEST_URI} !/.* [NC]
RewriteRule (.​*?)package\.php/*(.*​) /$1$2 [R=301,NE,L]

任何帮助都将不胜感激。

您的规则如下:

# Removes package.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} /package\.php\?(\S+)\s [NC]
RewriteRule ^ /%1? [R=301,NE,L]

#Redirects hotel pages to package.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /package.php?/$1 [L,QSA]

你的规则是这样的:

# Removes package.php from ExpressionEngine URLs
RewriteCond %{THE_REQUEST} /package\.php\?(\S+)\s [NC]
RewriteRule ^ /%1? [R=301,NE,L]

#Redirects hotel pages to package.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /package.php?/$1 [L,QSA]

这看起来会奏效。但是我要到11月23日星期一才能测试它。看起来它会工作的。但我要到11月23日星期一才能测试它。