【发布时间】:2016-04-09 12:08:30
【问题描述】:
我正在使用 Nette 框架,但我的主机中的根文件夹存在一些问题。
我的托管结构:
root
- demo
- www
- index.php
- www
默认情况下,我必须使用这个 URL 地址“www.demo.example.com/www”来访问文件 index.php。但是,我不想访问带有“www”后缀的网站。 Soooo 我在根文件夹中创建了这个 .htaccess 文件。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ /www/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/www/
RewriteRule ^(.*)$ /www/$1
</IfModule>
在 demo/www 文件夹中,我正在使用这个 .htaccess
# Apache configuration file (see httpd.apache.org/docs/2.2/mod/quickreference.html)
# disable directory listing
Options -Indexes
# enable cool URL
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# prevents files starting with dot to be viewed by browser
RewriteRule /\.|^\. - [F]
# front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L]
</IfModule>
# enable gzip compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript text/javascript application/javascript application/json
</IfModule>
# allow combined JavaScript & CSS. Inside of script.combined.js you could use <!--#include file="script.js" -->
<IfModule mod_include.c>
<FilesMatch "\.combined\.(js|css)$">
Options +Includes
SetOutputFilter INCLUDES
</FilesMatch>
</IfModule>
但是通过这种方式,我可以使用“www.demo.example.com”和“www.demo.example.com/www”访问网站,但我不想使用前缀“www”访问,我该怎么办?
感谢您的回答!
【问题讨论】:
标签: php apache .htaccess mod-rewrite