2013-02-19 111 views
0

我有一个文件夹命名为我的网站“关键词”,像这样的:http://www.mysite.com/keywords/显示索引页面所有链接到文件夹

在文件夹我只有一个index.php文件。无论在文件夹后面输入什么内容,我都需要index.php来显示。例如,http://www.mysite.com/keywords/this-is-a-test应显示index.php文件的内容,但不更改URL。

我试过的一切似乎都失败了 - 我正在使用我的/关键字/文件夹中的.htaccess。无论我在那里放置什么,我似乎都不断收到404错误。任何帮助将不胜感激,我敢肯定,这是一个小而简单的事情,我只是不知道该怎么做。

这是我目前有:

RewriteEngine on 
RewriteRule - index.php [L] 

这里的问题是,它只能与他们破折号去链接时工作。

例如,

http://www.mysite.com/keywords/testing-this 

确实工作。但这是行不通的:

http://www.mysite.com/keywords/testingthis 

任何帮助,将不胜感激。

回答

0
RewriteEngine On 
RewriteBase/ #make sure your website is located in root directory, if not you have to add directory here... 
RewriteRule ^keywords/testingthis$ /keywords/index.php$1 [L] 
0

你可以试试这个:

Options +FollowSymlinks 
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_URI} !index\.php [NC] 
RewriteCond %{REQUEST_URI} ^/keywords/.+ [NC] 
RewriteRule .*  keywords/index.php [L] 

地图默默:

http://www.mysite.com/keywords/anything

要:

http://www.mysite.com/keywords/index.php

没有任何内容传递给index.php,因为OP没有在问题中提到该要求。

字符串keywords被假定为固定的,而anything被假定为动态的。

anything必须至少保留一个字符才能应用规则。

对于永久和可见重定向,请将[L]替换为[R=301,L]

相关问题