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 - Fatal编程技术网

.htaccess 在浏览器中输入网页时,域后的第一个斜杠将被删除

.htaccess 在浏览器中输入网页时,域后的第一个斜杠将被删除,.htaccess,.htaccess,有时,当我在浏览器中点击我的网页地址时,它会删除域后的第一个斜杠 示例: www.mywebsite.com/scripts/script_6.php->尝试加载www.mywebsite.comscripts/script_6.php www.mywebsite.com/test.php->尝试加载www.mywebsite.comtest.php 再次输入后,它将加载页面 A.htaccess设置必须错误: RewriteBase / ErrorDocument 404 http://www

有时,当我在浏览器中点击我的网页地址时,它会删除域后的第一个斜杠

示例:

www.mywebsite.com/scripts/script_6.php->尝试加载www.mywebsite.comscripts/script_6.php www.mywebsite.com/test.php->尝试加载www.mywebsite.comtest.php

再次输入后,它将加载页面

A.htaccess设置必须错误:

RewriteBase /
ErrorDocument 404 http://www.mywebsite.com/oops.php
ErrorDocument 401 /notallowed.php
RewriteEngine On    # Turn on the rewriting engine

#Gzip
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x- javascript application/javascript
</ifmodule>
#End Gzip



RewriteCond %{HTTP_HOST} ^mywebsite\.com
RewriteRule ^(.*)$ http://www.mywebsite.com$1 [R=permanent,L]


DirectoryIndex index6.php

RewriteRule    ^termsofuse/?$    termsofuse.php    [NC,L]    # Handle requests for "adpolicy"
RewriteRule    ^privacy-policy/?$    privacy-policy.php    [NC,L]    # Handle requests for "adpolicy"
RewriteRule    ^newcampaign/?$    newcampaign.php    [NC,L]    # Handle requests for "newcampaign"
RewriteRule    ^howitworks/?$    howitworks3.php    [NC,L]    # Handle requests for "howitworks"
RewriteRule    ^signin/?$    login.php    [NC,L]    # Handle requests for "signin"
RewriteRule    ^reset_password/?$    reset_password.php    [NC,L]    # Handle requests for "register"
RewriteRule    ^error404/?$    oops2.php    [NC,L]    # Handle requests for "register"
RewriteRule    ^error/?$    oops2.php    [NC,L]    # Handle requests for "register"
RewriteRule    ^error401/?$    notallowed.php    [NC,L]    # Handle requests for "register"
RewriteRule    ^notallowed/?$    notallowed.php    [NC,L]    # Handle requests for "register"

#php_flag display_startup_errors on
#php_flag display_errors on
#php_flag html_errors on
#php_flag  log_errors on
#php_value error_log  PHP_errors.log

AddType text/x-component .htc

#ez lehet nem is kell mert gzip van
# compress text, HTML, JavaScript, CSS, and XML
SetOutputFilter DEFLATE 
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

#Enable Browser caching
#<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
Header set Cache-Control "max-age=2592000"
Header append Cache-Control "public"
#</FilesMatch>

#Vary: Accept-Encoding header
<IfModule mod_headers.c>
  <FilesMatch "\.(js|css|xml|gz|html)$">
    Header append Vary: Accept-Encoding
  </FilesMatch>
</IfModule>


# Enable expirations
<IfModule mod_expires.c>
ExpiresActive On 
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>


#Enable Compression
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>



<ifModule mod_headers.c>
    Header set Connection keep-alive
</ifModule>
RewriteBase/
错误文档404http://www.mywebsite.com/oops.php
ErrorDocument 401/notallowed.php
重写引擎打开#打开重写引擎
#Gzip
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
#结束Gzip
重写cond%{HTTP_HOST}^mywebsite\.com
重写规则^(.*)$http://www.mywebsite.com$1[R=永久性,L]
directoryIndex6.php
重写规则^termsofuse/?$termsofuse.php[NC,L]#处理“adpolicy”请求
重写规则^privacy policy/?$privacy-policy.php[NC,L]#处理“adpolicy”请求
重写规则^newcampaign/?$newcampaign.php[NC,L]#处理“newcampaign”的请求
重写规则^howitworks/?$howitworks3.php[NC,L]#处理“howitworks”的请求
重写规则^signin/?$login.php[NC,L]#处理“登录”请求
重写规则^reset_password/?$reset_password.php[NC,L]#处理“注册”请求
重写规则^error404/?$oops2.php[NC,L]#处理“注册”请求
重写规则^error/?$oops2.php[NC,L]#处理“注册”请求
重写规则^error401/?$notallowed.php[NC,L]#处理“注册”请求
重写规则^notallowed/?$notallowed.php[NC,L]#处理“注册”请求
#php_标志显示_启动_错误
#php_标志显示上的错误
#上的php_标志html_错误
#上的php_标志日志_错误
#php\u值错误\u日志php\u错误.log
AddType text/x-component.htc
#ez lehet nem是kell mert gzip van
#压缩文本、HTML、JavaScript、CSS和XML
SetOutputFilter放气
AddOutputFilterByType泄气文本/普通
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE应用程序/xml
AddOutputFilterByType DEFLATE应用程序/xhtml+xml
AddOutputFilterByType DEFLATE应用程序/rss+xml
AddOutputFilterByType DEFLATE应用程序/javascript
AddOutputFilterByType DEFLATE应用程序/x-javascript
#删除浏览器错误
浏览器匹配^Mozilla/4 gzip纯文本/html
浏览器匹配^Mozilla/4\.0[678]无gzip
BrowserMatch\bMSIE!没有gzip!仅限gzip文本/html
头附加用户代理
#启用浏览器缓存
#
标题集缓存控制“最大年龄=2592000”
标头附加缓存控制“公共”
#
#改变:接受编码头
头附加变量:接受编码
#启用过期
过期于
ExpiresByType图像/jpg“访问1个月”
过期按类型图像/jpeg“访问1个月”
ExpiresByType image/gif“访问1个月”
ExpiresByType图像/png“访问1个月”
ExpiresByType文本/css“访问1个月”
ExpiresByType text/html“访问1个月”
过期按类型应用程序/pdf“访问1个月”
ExpiresByType文本/x-javascript“访问1个月”
过期按类型应用程序/x-shockwave-flash“访问1个月”
过期按类型图像/x图标“访问1年”
ExpiresDefault“访问1个月”
#启用压缩
mod_gzip_on Yes
是的
mod|gzip|item|u include file.(html?| txt | css | js | php | pl)$
mod_gzip_item_包含处理程序^cgi脚本$
mod_gzip_项目包括mime^text/*
mod_gzip_item_包括mime^application/x-javascript*
mod_gzip_项_排除mime^image/*
mod_gzip_item_排除rspheader^内容编码:.*gzip*
标题集连接保持活动状态

这是由于您的
www
强制执行规则造成的。请记住,
RewriteRule
中捕获的字符串没有租约

替换为:

RewriteCond %{HTTP_HOST} ^mywebsite\.com$ [NC]
RewriteRule ^ http://www.mywebsite.com%{REQUEST_URI} [R=301,L,NE]

确保在新浏览器中进行测试,以避免浏览器缓存问题。

如果没有www,仍然是错误的
mywebsite.com/test1.php
变成
http://www.mywebsite.comtest1.php/
。有了www,一切都很好,看起来总是很好。因此,当我在没有www标记的情况下进入网页时,问题就出现了,这是由于浏览器缓存造成的。在新浏览器中测试。不,不是。我每次尝试都会清除缓存。我创建了一个新文件(在清除缓存后)并输入了
mywebsite.com/test2.php
。它已成为
http://www.mywebsite.comtest2.php/
在这种情况下,我怀疑您的问题中没有显示一些代码/规则/框架。尝试编辑答案。我在目标URL中使用了
%{REQUEST\u URI}