无法在不向URL添加问号的情况下访问链接

时间:2015-12-16 11:40:57

标签: javascript php html .htaccess

每次点击网址时,我都会收到404.那是因为无法找到该网页。但是当我在.domain之后添加一个问号时,会找到该页面。当我将网站托管在子域文件夹中时,这不是问题。访问页面需要一个问号,我不想有问号。

请参阅网址:http://www.ankehesselmann.nl/

我正在使用StaceyApp

这是我的.htaccess

RewriteEngine on

# Some hosts require a rewritebase rule, if so, uncomment the RewriteBase line below. If you are running from a subdirectory, your rewritebase should match the name of the path to where stacey is stored.
ie. if in a folder named 'stacey', RewriteBase /stacey
RewriteBase /stacey

ErrorDocument 404 /404.html

# Rewrite any calls to *.html, *.json, *.xml, *.atom, *.rss, *.rdf or *.txt if a folder matching * exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !public/
RewriteCond %{DOCUMENT_ROOT}/public/$1.$2 !-f
RewriteRule (.+)\.(html|json|xml|atom|rss|rdf|txt)$ $1/ [L]

#Add a trailing slash to directories
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.)
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ([^/]+)$ $1/ [L]

# Rewrite any calls to /* or /app to the index.php file
RewriteCond %{REQUEST_URI} /app/$
RewriteRule ^app/ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ index.php?$1 [L]

# Rewrite any file calls to the public directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !public/
RewriteRule ^(.+)$ public/$1 [L]

1 个答案:

答案 0 :(得分:0)

我猜你的.htaccess中的RewriteBase被设置为错误的文件夹 虽然我无法解释为什么它如你所说的那样与问号一起工作,但我会尝试正确设置RewriteBase。

如果有的话,你必须把子文件夹(从域名路径到你的索引文件)。 E.g:

网站位于:example.com/folder1/sub /

RewriteBase /folder1/sub/

如果您的网站没有子文件夹:

RewriteBase /

如果您没有子文件夹,可以尝试删除该行,但如果设置为/(斜杠)则不应该出现任何问题。