0

好的,我正在尝试使用 Lando (landocms.com),并且正在尝试使用漂亮的 urls 选项。

基本上默认情况下,Lando 会创建如下链接:domain.com/index.php/page。据说,有一种方法可以删除 index.php,使链接变为:domain.com/page。我按照指示创建了一个 .htaccess,但是它不起作用。

这是我正在使用的 .htaccess:

<IfModule mod_rewrite.c>
  RewriteCond   %{REQUEST_FILENAME}   !-f 
  RewriteCond   %{REQUEST_FILENAME}   !-d 
  RewriteRule   ^(.*)$                index.php/$1  [L]
</IfModule>

我尝试了很多变体,/index.php/,index.php?还有更多,但没有工作。根据 HostGator 的说法,一切都应该没问题。有什么想法吗?我觉得我快疯了哈哈。

谢谢!

4

2 回答 2

2

为 CMS 重写是一种两层方法。首先,你需要设置你的.htaccess(我在这里为你放了一个更安全的):

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .+ index.php [QSA,L]

然后,LandoCMS 允许您index.php通过在管理面板中打开适当的设置来从生成的地址中删除。有关更多信息,请参阅此链接

如果.htaccess我给你的内容不起作用,那么只需使用 CMS 给你的内容。

于 2013-02-20T05:09:39.383 回答
0

您想index.php从任何 URL 中删除该部分,但index.php仍然通过处理传入的友好 URL

RewriteEngine On

# remove index.php and redirect client
RewriteCond %{ENV:REDIRECT_SEO} ^$
RewriteRule ^/?index.php/(.*) /$1 [R,L]

# process friendly URL
RewriteCond %{REQUEST_URI} !^/index.php/
RewriteRule .+ /index.php/$0 [E=SEO:1,L]

环境设置E=SEO:1可防止无限循环。

于 2013-02-20T11:59:15.277 回答