如何在.HTACCESS文件中从另一个文件夹设置默认主页?

时间:2021-06-11 16:03:34

I created a site and make its URL seo friendly like www.mywebsite.com/home.
but actual homepage is in my /SomeFolder/index.php which is rewrite its url to /home.
Now i want to set /home url as a default page in htaccess file. But when i set this.

我创建了一个网站,并使其URL友好,如www.mywebsite.com/home。但实际的主页在我的/SomeFolder/index.php中,它将其URL重写为/ home。现在我想将/ home url设置为htaccess文件中的默认页面。但是当我设定这个。

DirectoryIndex /home

I got the 500 error. One way is to give the redirection in index.php so it will redirect me to the /home page. but i think its a weird method.
Is there any other way??

我得到了500错误。一种方法是在index.php中给出重定向,这样它就会将我重定向到/ home页面。但我认为这是一种奇怪的方法。还有别的办法吗?

Thanks

4 个解决方案

#1


0  

this best article for create pretty URLs : http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/

这篇创建漂亮网址的最佳文章:http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/

#2


0  

Try DirectoryIndex home/index.php

试试DirectoryIndex home / index.php

#3


0  

use this one , hope this will helpful for you

使用这个,希望这对你有所帮助

Options +FollowSymLinks

RewriteEngine on
RewriteRule home(.*)\$ index.php

#4


0  

Remove that DirectoryIndex line.

删除该DirectoryIndex行。

You'll need this rule in your DocumentRoot/.htaccess:

您需要在DocumentRoot / .htaccess中使用此规则:

RewriteEngine on
RewriteRule ^home/?$ /SomeFolder/index.php [L,NC]

#1


0  

this best article for create pretty URLs : http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/

这篇创建漂亮网址的最佳文章:http://net.tutsplus.com/tutorials/other/using-htaccess-files-for-pretty-urls/

#2


0  

Try DirectoryIndex home/index.php

试试DirectoryIndex home / index.php

#3


0  

use this one , hope this will helpful for you

使用这个,希望这对你有所帮助

Options +FollowSymLinks

RewriteEngine on
RewriteRule home(.*)\$ index.php

#4


0  

Remove that DirectoryIndex line.

删除该DirectoryIndex行。

You'll need this rule in your DocumentRoot/.htaccess:

您需要在DocumentRoot / .htaccess中使用此规则:

RewriteEngine on
RewriteRule ^home/?$ /SomeFolder/index.php [L,NC]