有时当我在浏览器中点击我的网页地址时,会删除域后的第一个斜杠。
示例:
www.mywebsite.com/scripts/script_6.php - >试图加载www.mywebsite.comscripts / script_6.php www.mywebsite.com/test.php - >试图加载www.mywebsite.comtest.php
再次输入后,会加载页面。
.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>
答案 0 :(得分:0)
这是由于您的www
强制执行规则。请记住RewriteRule
中已捕获的字符串没有租借/
。
将其替换为:
RewriteCond %{HTTP_HOST} ^mywebsite\.com$ [NC]
RewriteRule ^ http://www.mywebsite.com%{REQUEST_URI} [R=301,L,NE]
请务必在新浏览器中对其进行测试,以避免出现浏览器缓存问题。