0

LE:发现我的解释能力很差,所以我会在最后做一个快速的主题 tl;dr。

我最近收到了一个项目,该项目意味着在 CMSMS(CMS Made Simple)上定制一个网站。网站版本是1.11.2,我使用 Apache 和 mod_rewrite 来处理 url 重写。我一直在尝试解决与 URL 重写相关的一件小事,但我根本无法克服它。

该网站已经安装了一个博客模块,CGLog。为了显示博客的内容,我需要一个页面(以及该页面的模板,但我们会将模板排除在讨论之外,因为这与问题无关)将所有帖子溢出。基本上,一般类别/存档页面。因此,我创建了一个名为“博客”的页面,其 URL 为“博客”。到目前为止,不考虑博客,我们将拥有类似 example.com/blog 的内容。

该博客可以选择在每篇文章之前添加前缀。所以我可以制作类似 example.com/any_prefix_here/title-of-post 的东西。此外,在博客文章中,它不会记录归档/类别页面的调用方式。所以我一直在使用这个前缀选项来使 url 看起来一样。例如:example.com/blog 以及在文章 example.com/blog(添加为前缀)/title-of-the-post中时。

现在,问题是如果我尝试保留名为“blog”的博客页面的名称,我将无法作为 example.com/blog 访问它,否则我将获得 403 禁止。如果我通过 example.com/anything/blog 访问它,它将起作用。如果我将页面命名为 blog2,那么我可以通过 example.com/blog2 访问它。我不知道“博客”这个词是怎么回事。我也无法弄清楚如何绕过 403 禁止。

我什至尝试通过 .htaccess 以某种方式重写它,但没有成功。

这是我目前的 htaccess。

    # Attempt to override some php settings, these settings may be helpful on some hosts if your
# default configuration does not meet CMS's minimum requirements, and your host
# has given your account appropriate permissions
#php_value upload_max_filesize "10M"
#php_value session_save_path "tmp/cache"

#php_flag magic_quotes_gpc Off
#php_flag register_globals Off
#php_flag session.use_trans_sid Off

# (this is important, so uncomment if your host permit)
Options -Indexes
ServerSignature Off

Options +FollowSymLinks

# To prevent E_STRICT problems with PHP 5.3+ you can uncomment the following lines
# Note: These settings should only be enabled for production sites!
#php_flag display_startup_errors 0
#php_flag display_errors 0
#php_flag html_errors 0
#php_value docref_root 0
#php_value docref_ext 0

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# redirects /index.php?page=asfd to /asdf
RewriteCond %{THE_REQUEST} /index\.php\?page=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L,NE]

# redirects /index.php/asfd to /asdf
RewriteCond %{THE_REQUEST} /index\.php/([^?\s]+)\s [NC]
RewriteRule ^ /%1 [R=302,L,NE]

RewriteCond %{THE_REQUEST} ^.*/index\.php 
RewriteRule ^(.*)index.php$ /$1 [R=301,L] 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA,L]

RewriteCond %{HTTP_HOST} ^connsys.ro
RewriteRule (.*) http://www.connsys.ro/$1 [R=301,L]
</IfModule>


<IfModule mod_header.c>
# Disable ETags
Header unset ETag
FileEtag None
</IfModule>

<IfModule mod_deflate.c>
# Compress css, plaintext, xml, gif, and images in transport.
AddOutputFilterByType DEFLATE text/css text/plain text/xml image/gif image/jpeg image/png
</IfModule>

<IfModule mod_expires.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
# Set expires tags on various files... so that the browser wont attempt to reload them.
ExpiresActive On
ExpiresDefault "access plus 1 year"
<IfModule mod_header.c>
  # Setting cache control to public allowes proxy servers to cache the items too.
  Header set Cache-Control "public"
</IfModule>
</FilesMatch>
</IfModule>

# 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

# Or, compress certain file types by extension:
<files *.html>
SetOutputFilter DEFLATE
</files>

<IfModule mod_headers.c>
# WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf|woff)$">
    Header set Cache-Control "max-age=604800, public"
</FilesMatch>
</IfModule>

Tl;dr:博客页面的 url 重写问题/权限问题。页面称为“博客”,slug/url 称为“博客”。我无法以 example.com/blog 的身份访问博客,因为我被禁止 403。如果我以 example.com/anything/blog 的身份访问博客,它就可以工作。如果我将页面重命名为 blog2,它将作为 example.com/blog2 工作。

我应该如何处理这个问题?如果您不投反对票并告诉我我做错了什么,以防我解释错误,我将不胜感激。

谢谢

4

1 回答 1

1

有没有一个真正的目录叫做blog? 没有禁用索引文件/自动索引,或者权限不正确?

于 2016-11-14T01:17:05.230 回答