2009-04-30 80 views
0

为了将我的动态URL即www.3idiots.co.in/index.php转换为静态网址即www.3idiots.co.in/index.html,我编辑了我的.htccess文件,并把它下面的代码:网址重写页面未找到错误

RewriteEngine On 
RewriteRule ^index.php$ /index.html [R] 

当我上载的根目录下这个文件,并尝试打开网页,我得到了错误

404页没有发现错误,万维网找不到.3idiots.co.in/index.html。

+1

嗯,我去了http://www.3idiots.co.in/index.html,果然,页面不在那里。你有没有检查你的文件权限?也许HTTPD用户看不到它。 – 2009-04-30 12:20:23

+0

www.3idiots.co.in/index.php转到此页...我想将它转换为www.3idiots.co.in/index.html – MAX 2009-04-30 12:28:04

回答

0
RewriteEngine On 

# Send the user to index.html 
RewriteRule ^index.php$ /index.html [R] 

# Tell the server that index.html really means index.php 
RewriteRule ^index.html$ /index.php 
+0

嘿格雷格,thnx为你关心....我试过这个代码,但在浏览器中它显示www.3idiots.co.in/index.php,但我希望它在HTML – MAX 2009-04-30 12:22:03

0

尝试下列规则:

RewriteCond %{THE_REQUEST} ^GET\ /index\.php 
RewriteRule ^index\.php$ /index.html [L,R=301] 

RewriteRule ^index\.html$ index.php [L] 

的第一条规则的/index.php每一个直接请求外部重定向到/index.html。第二条规则将内部/index.html的请求重写为/index.php

+0

嘿秋实....它不工作的朋友......任何其他解决方案你有在你的脑海?????????????? – MAX 2009-04-30 12:27:06

+0

你确定mod_rewrite已经加载并正在工作吗?你有没有试过一个简单的规则,比如'RewriteRule^http://example.com/ [R]'看看它是否工作? – Gumbo 2009-04-30 12:28:37

+0

你确定..但它不工作 – MAX 2009-04-30 12:32:27

1

你必须有一个名为index.html的文件。现在你不知道。重写/重定向工作正常,你只是重定向到一个不存在的页面/文件。

我对你实际要做的事有些困惑。如果您只想将index.php移至index.html,请重命名该文件。重写使得如果有人试图打开index.php,他们将被重定向到index.html,但你仍然必须有一个index.html文件,以便将它们重定向到

0

确定模式改写已启用&可以工作吗?

1)创建一个名为任何你想在它found.html一个HTML页面,但一些文本,以确保它的加载(不是空白基本)和把这个叫“的.htaccess”的文件:

RewriteEngine叙述上
RewriteBase/
重写规则^ find.html $ /found.html [L]

2)同时上传你的.htaccess和域的根目录下的文件found.html

3 )试着加载-www.exampl e.com/find.html(当然还有你的真实领域)。如果mod_rewrite可用,你应该在浏览find.html时看到found.html的内容(这在物理上并不存在)。

如果它不能正常工作,请尝试:

RewriteEngine叙述上
RewriteBase/
重写规则^ find.html $ found.html [L]

0

在Apache的conf文件,你还需要以确保AllowOverride设置为允许处理.htaccess的值。

通常它的AllowOverride所有

0

RewriteEngine叙述在

重写规则^ $ index.html的指数。PHP

重写规则^ $的index.htm/$的index.php [L]

0

选项+了FollowSymLinks
RewriteEngine叙述上
重写规则^ index.html的$的index.php

尝试此代码.. 。

它将为你的问题的工作/ ..

最好的运气
如果它解决您的问题..
访问我的网站