我在www.mywebsite.com上安装了Silverstripe(我把它作为一个例子)
我正在www.mywebsite.com/test
上测试Wordpress这是我根文件夹中的.htaccess文件:
### SILVERSTRIPE START ###
# Deny access to templates (but allow from localhost)
< Files *.ss >
Order deny,allow<br>
Deny from all<br>
Allow from 127.0.0.1
< /Files >
# Deny access to IIS configuration
< Files web.config >
Order deny,allow
Deny from all
< /Files >
# Deny access to YAML configuration files which might include sensitive information
< Files ~ "\.ya?ml$">
Order allow,deny
Deny from all
< /Files>
# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
< IfModule mod_env.c>
# Ensure that X-Forwarded-Host is only allowed to determine the request
# hostname for servers ips defined by SS_TRUSTED_PROXY_IPS in your _ss_environment.php
# Note that in a future release this setting will be always on.
SetEnv BlockUntrustedIPs true
< /IfModule>
< IfModule mod_rewrite.c>
# Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
< IfModule mod_dir.c>
DirectoryIndex disabled
< /IfModule>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine Off
# Enable HTTP Basic authentication workaround for PHP running in CGI mode
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Deny access to potentially sensitive files and folders
RewriteRule ^vendor(/|$) - [F,L,NC]
RewriteRule silverstripe-cache(/|$) - [F,L,NC]
RewriteRule composer\.(json|lock) - [F,L,NC]
# Process through SilverStripe if no file with the requested name exists.
# Pass through the original path as a query parameter, and retain the existing parameters.
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* framework/main.php?url=%1 [QSA]
# If framework isn't in a subdirectory, rewrite to installer
RewriteCond %{REQUEST_URI} ^(.*)/framework/main.php$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . %1/install.php? [R,L]
< /IfModule><br>
### SILVERSTRIPE END ###
< IfModule pagespeed_module>
ModPagespeed Off
</IfModule>
< IfModule mod_expires.c><br>
ExpiresActive Off<br>
< /IfModule>
/test/.htaccess上的代码:
< IfModule mod_rewrite.c><br>
SetEnv HTTP_MOD_REWRITE On<br>
RewriteEngine On<br>
RewriteBase /<br>
RewriteCond %{REQUEST_URI} !/test<br>
RewriteEngine On<br>
RewriteCond %{REQUEST_FILENAME} !-f<br>
RewriteCond %{REQUEST_FILENAME} !-d<br>
RewriteRule . /index.php [L]<br>
< /IfModule>
有什么想法吗?注意:&lt; br&gt;没有显示在实际文件中,并且&lt;之间没有空格。和&gt;
我得到了所有文件的列表。我的index.php文件甚至没有正确显示,URL从/ test更改为test /?url = / test
我使用zoom.ph共享主机。
更新
我在根.htacccess文件中的新代码:
RewriteEngine On
# Change any direct URLs (www.unclebubby.com...) to the subdomain (wavs.unclebubby.com)
RewriteCond %{HTTP_HOST} ^(www\.)?collegeconnect\.ph$ [NC]
RewriteCond %{REQUEST_URI} ^/test/(.*)$ [NC]
RewriteRule .* http://test.collegeconnect.ph/%1 [R=301,L]
RewriteCond %{REQUEST_URI} !/test
# If there is a .htm at the end of the URL, get rid of it (due to migration of site from FrontPage)
RewriteCond %{REQUEST_URI} ^/(.+)\.htm$ [NC]
RewriteRule ^.+\.htm$ /%1 [R=301,L]
RewriteBase /
### SILVERSTRIPE START ###
答案 0 :(得分:1)
我测试了这个,你的东西似乎工作得很好。确保你的htaccess没有错误。你可以检查一下apache.log。
以下是我使用的内容:
DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/test
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
这将我成功重定向到Wordpress设置页面(全新安装)。
答案 1 :(得分:0)
首先,test / .htaccess中的RewriteBase是错误的。它不是&#34; /&#34; (root),但&#34; / test /&#34; (因为文件在那里)。
其次,你有&#34; RewriteEngine On&#34;在你的测试/ .htaccess中两次 - 这可能不是错误,但无论如何都不需要。
第三 - 你的test / .htaccess文件本身被行禁用:
RewriteCond %{REQUEST_URI} !/test
表示 - 不的所有请求都有&#34; test&#34;在URL中,没有请求&#34; test&#34;文件夹可以满。您的测试/ .htaccess应如下所示:
< IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
< /IfModule>
BONUS:Silverstripe会扫描安装它的整个文件夹并将这些类添加到其清单中,这意味着您应该通过放置名为&#34; _manifest_exclude&#的空文件来排除wordpress(即文件夹&#34; test&#34;) 34;在它。
答案 2 :(得分:0)
在根据路径的.htaccess文件中提及'RewriteBase'中的文件夹名称
RewriteBase '/test/'
其中SilverStripe是你提到的文件夹名称
{{1}}
请记得在文件夹名称前后添加斜杠。如果它不起作用,请告诉我。感谢