.htaccess影响我的php包括
嗨,我已经在这上面呆了好几天了,我还不算太高,请原谅我 如果我有以下链接.htaccess影响我的php包括,php,.htaccess,mod-rewrite,Php,.htaccess,Mod Rewrite,嗨,我已经在这上面呆了好几天了,我还不算太高,请原谅我 如果我有以下链接 <a href="<?=$linkLocations?>">Best Locations</a> 在我的.htaccess文件中: RewriteEngine on RewriteCond %{HTTP_HOST} !^$ RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteCond %{HTTPS}s ^on(
<a href="<?=$linkLocations?>">Best Locations</a>
在我的.htaccess文件中:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteRule ^([a-zA-Z0-9\_\-]+)$ subpage.php?page=$1 [NC]
RewriteRule ^([a-zA-Z0-9\_\-]+)/$ subpage.php?page=$1 [NC]
在subpage.php中:
if ($page == 'best-locations') {
include($ROOT .'/display/bestLocations.php');
$mainContent .= $locationContent;
}
并且bestLocations.php有sql查询等。但因为我得到了404我知道我甚至没有得到那么远的权利?这是在wamp上运行的实时站点的下载版本(如果有帮助的话)。你的投入是无与伦比的
编辑-
通过从my.htaccess中删除以下行,可以解决此问题
# compress text, html, javascript, css, xml:
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
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/png A2592000
ExpiresByType image/x-icon A2592000
ExpiresByType text/css A604800
ExpiresByType application/javascript A604800
ExpiresByType application/x-shockwave-flash A2592000
<FilesMatch "\.(gif¦jpe?g¦png¦ico¦css¦js¦swf)$">
Header set Cache-Control "public"
</FilesMatch>
压缩文本、html、javascript、css、xml:
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
过期于
ExpiresByType图像/gif A2592000
过期按类型图像/jpeg A2592000
ExpiresByType图像/jpg A2592000
ExpiresByType图像/png A2592000
ExpiresByType图像/x图标A2592000
ExpiresByType文本/css A604800
ExpiresByType应用程序/javascript A604800
过期按类型应用/x-shockwave-flash A2592000
标头集缓存控制“公共”
失败的原因有很多 “HTTP 404:Not Found”响应意味着未调用脚本subpage.php(因此也是bestLocations.php) 您可能希望调试重写过程: 这个.htaccess有效吗
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([a-zA-Z0-9\_\-]+)/$ subpage.php?page=$1 [NC]
RewriteRule ^([a-zA-Z0-9\_\-]+)$ subpage.php?page=$1 [NC]
出于测试目的,我删除了与HTTPS相关的内容,并在末尾交换了两行,因此首先替换“x/”,然后替换“x”
另外,您提到此代码是从某处下载的。该来源是否提到了所需的环境?这个可下载系统在其他机器上工作吗
更新PS:为了100%确保您的服务器接受.htaccess文件:尝试在.htaccess文件中写入垃圾,然后查看是否收到“HTTP 500:内部服务器错误”响应。如果没有,则不会解释您的.htaccess。谢谢Daniel,我将尝试您的建议并再次发布,源代码只是一个自定义CMS,我正试图在本地环境中使用,但只能显示index.php,因此farOk Daniel-由于持久性和您对调试帖子的引用,它现在可以工作了。欣赏it@phillydigital我很高兴能帮上忙。我想知道,我失败的原因是什么?用我删除的代码添加一个编辑,使其工作
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([a-zA-Z0-9\_\-]+)/$ subpage.php?page=$1 [NC]
RewriteRule ^([a-zA-Z0-9\_\-]+)$ subpage.php?page=$1 [NC]