.htaccess不在实时站点上工作,但在本地主机上工作?
我正在使用ExpressionEngine,希望从我的URL中删除.htaccess不在实时站点上工作,但在本地主机上工作?,.htaccess,mod-rewrite,expressionengine,.htaccess,Mod Rewrite,Expressionengine,我正在使用ExpressionEngine,希望从我的URL中删除index.php。我已将此.htaccess文件保存在根文件夹中。它在本地主机上工作得很好,但是当我将它上传到服务器时,它就不工作了。地址栏中会显示正确的URL,但页面仍保留在主页上。有什么建议吗 <IfModule mod_rewrite.c> # Enable Rewrite Engine # ------------------------------ RewriteEngine On
index.php
。我已将此.htaccess文件保存在根文件夹中。它在本地主机上工作得很好,但是当我将它上传到服务器时,它就不工作了。地址栏中会显示正确的URL,但页面仍保留在主页上。有什么建议吗
<IfModule mod_rewrite.c>
# Enable Rewrite Engine
# ------------------------------
RewriteEngine On
RewriteBase /
# Redirect index.php Requests
# ------------------------------
RewriteCond %{THE_REQUEST} ^[^/]*/index\.php [NC]
RewriteCond %{THE_REQUEST} ^GET
RewriteRule ^index\.php(.+) $1 [R=301,L]
# Standard ExpressionEngine Rewrite
# ------------------------------
RewriteCond $1 !\.(css|js|gif|jpe?g|png) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
#启用重写引擎
# ------------------------------
重新启动发动机
重写基/
#重定向index.php请求
# ------------------------------
RewriteCond%{THE_REQUEST}^[^/]*/index\.php[NC]
RewriteCond%{THE_REQUEST}^GET
重写规则^index\.php(+)$1[R=301,L]
#标准表达式引擎重写
# ------------------------------
重写秒$1!\。(css | js | gif | jpe?g | png)[NC]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$/index.php/$1[L]
确保您的配置允许.htaccess
文件,并且您的服务器已安装并激活了mod_rewrite
在MacOSX上,您可以在/etc/apache2/httpd.conf
找到此文件。查找
指令并将其更改为:
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
</Directory>
如果您希望使用GUI重新启动Apache,请转到Apple>System Preferences>Share并切换Web共享服务旁边的复选框
如果您使用的是Windows或任何风格的Linux,同样的方法也适用,但是Apache配置可能位于不同的位置,尤其是如果您使用的是或
此外,供参考,Ellisab for的“官方支持方法”如下:
<IfModule mod_rewrite.c>
RewriteEngine On
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# If 404s, "No Input File" or every URL returns the same thing
# make it /index.php?/$1 above (add the question mark)
</IfModule>
重新启动发动机
#删除index.php
重写秒$1!\。(gif | jpe?g | png)$[NC]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^(.*)$/index.php/$1[L]
#如果404s,“无输入文件”或每个URL返回相同的内容
#将其设置为/index.php?/$1以上(添加问号)
<IfModule mod_rewrite.c>
RewriteEngine On
# Removes index.php
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
# If 404s, "No Input File" or every URL returns the same thing
# make it /index.php?/$1 above (add the question mark)
</IfModule>