Index.php使用BASEURL连接到内页连接问题htaccess

时间:2015-12-18 17:31:13

标签: php .htaccess

我在将内页连接到index.php文件时遇到问题。它使用BASEURL。

有一段代码丢失了(在.htaccess文件中),当你请求内部页面如/ about-us时,基本上会调用index.php。

代码段中有RewriteCond和RewriteRule。

 RewriteEngine On
 RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
 RewriteRule ^index\.php$ / [L,R=301]

 RewriteCond %{HTTP_HOST} ^www\.website\.com$ [NC]
 RewriteRule ^(.*)$ http://www.website.com/$1 [L,R=301

我知道这是假设将所有URL从非www指向www。但它的格式与此类似。

2 个答案:

答案 0 :(得分:2)

将它放在根目录中的.htaccess文件管理器中。将任何现有的url重写为index.php

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php

答案 1 :(得分:1)

如果您知道htacces重定向知识,请使用http://www.htaccessredirect.net/为您创建重定向条件。如果您在apache配置中启用了SymLinks,也可以使用以下代码

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]