我一直试图让这个网站在我的本地计算机上工作,但是由于.htaccess文件设置导致链接不再有效,而我试图改变这些设置是不成功的。页面内容位于数据库中,链接看起来像
<a href="<?=$linkLocations?>" id="bestLoc"<?=$activeBest?>>Best Locations</a>
该变量被定义为全局
$linkLocations = $URL . '/best-locations';
和bestLocations实际上是一个查询数据库的.php文件。 .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>
RewriteEngine on
fafaf
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 ^communities/([a-zA-Z0-9\_\-]+)$ communities/index.php?community=$1 [NC]
RewriteRule ^communities/([a-zA-Z0-9\_\-]+)/$ communities/index.php?community=$1 [NC]
RewriteRule ^communities/([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)$ communities/index.php?community=$1&commPage=$2 [NC]
RewriteRule ^communities/([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)/$ communities/index.php?community=$1&commPage=$2 [NC]
RewriteRule ^communities/([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)$ communities/index.php?community=$1&commPage=$2&model=$3 [NC]
RewriteRule ^communities/([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)/$ communities/index.php?community=$1&commPage=$2&model=$3 [NC]
RewriteRule ^([a-zA-Z0-9\_\-]+)$ subpage.php?page=$1 [NC]
RewriteRule ^([a-zA-Z0-9\_\-]+)/$ subpage.php?page=$1 [NC]
RewriteRule ^([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)$ subpage.php?page=$1&sp=$2 [NC]
RewriteRule ^([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)/$ subpage.php?page=$1&sp=$2 [NC]
RewriteRule ^([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)$ subpage.php?page=$1&sp=$2&spd=$3 [NC]
RewriteRule ^([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)/([a-zA-Z0-9\_\-]+)/$ subpage.php?page=$1&sp=$2&spd=$3 [NC]
我知道我在这里错过了很多,可能超出了我的深度,但如果有人能指出我的大方向,我将不胜感激;我在htaccess教程上度过了一个上午,但这对我来说仍然有点难度。
答案 0 :(得分:1)
尝试:
RewriteEngine on
RewriteRule ^([a-zA-Z0-9\_\-]+)$ subpage.php?page=$1 [NC,L]
现在(在你编辑之后),没有:
fafaf
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]