我正在使用以下代码将我的所有 php 文件访问到 /it 目录中,而没有指定扩展名,效果很好。换句话说,我只需编写“http://www.mydomain.com/it/about”就可以访问“ http://www.mydomain.com/it/about.php”。
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://www.mydomain.com/it/$1.php [L]
当我尝试访问http://www.mydomain.com/it/question_answers.php时也会发生同样的情况。我怎样才能直接访问 *"http://www.mydomain.com/it/question_answers.php"* 也写"http://www.mydomain.com/it/question-answers"?我在前面写了下面的流式代码,但它似乎不起作用。
Redirect 301 /question-answer http://www.mydomain.com/it/question_answer.php
因为如果我写“http://www.mydomain.com/it/question-answer”,浏览器会尝试打开页面: “http://www.mydomain.com/it/question-answer.php.php。 php.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php.php"
这篇文章的一个小摘要:
- 我有页面 *"http://www.mydomain.com/it/question_answers.php"*
- 通过代码的第一部分,我可以使用链接 *"http://www.mydomain.com/it/question_answers"*
- 我还想使用以下“http://www.mydomain.com/it/question-answers”访问同一页面
谢谢!