【发布时间】:2013-11-17 02:59:46
【问题描述】:
我一直在开发一个网站,但我的子域的 .htaccess 似乎无法正常工作。
我的子域中的 .htaccess 文件。
DirectoryIndex index.php
Options -MultiViews
RewriteEngine on
# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+home\.php\?page=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=302,L]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ home.php?page=$1 [L,QSA]
当我转到我的子域时,我可以找到我的 index.php,但是当我转到我的 home.php 或 /home 等时,它似乎不起作用,并重定向到我的 404 页面(已在我的根目录。
我的根目录 .htaccess 文件:
Options -MultiViews
RewriteEngine on
ErrorDocument 404 http://example.ca/error?id=404
ErrorDocument 403 http://example.ca/error?id=403
ErrorDocument 500 http://example.ca/error?id=500
RewriteCond %{http_host} ^www\.james-emerson\.ca [NC]
RewriteRule ^(.*)$ http://james-emerson.ca/$1 [R=301,NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteRule ^home$ index.php
我的根看起来像:
/
- content/
- include/
- sites/
- external/
- sbfg/ (subdomains subdirectory)
- content/
- include/
- .htaccess
- index.php
- home.php
- ...etc...
- .htaccess
- index.php
- ...etc...
如果您能提供帮助,我将不胜感激。提前致谢。
【问题讨论】:
标签: php apache .htaccess mod-rewrite redirect