【发布时间】:2022-01-12 15:39:14
【问题描述】:
我正在尝试从 url 中删除 .php 扩展名,但我不走运尝试在堆栈上提供给我的已知解决方案,但我需要帮助。 (Guide i followed) 我已将所需的 RewriteConditions 和规则添加到 .htaccess 文件中,并将我的 href 更新为以下内容,但它仍然无法正常工作。当我使用以下值保存 .htaccess 文件时,当我尝试访问它时出现“页面不存在”的错误。
.htaccess
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
RewriteCond %{REQUEST_URI} !^(.+)\.html$
RewriteCond %{REQUEST_URI} !^(.+)\.htm$
RewriteCond %{REQUEST_URI} !^(.+)\.php$
RewriteCond %{REQUEST_URI} !^(.+)\.js$
RewriteCond %{REQUEST_URI} !^(.+)\.css$
RewriteCond %{REQUEST_URI} !^(.+)\.jpg$
RewriteCond %{REQUEST_URI} !^(.+)\.png$
RewriteCond %{REQUEST_URI} !^(.+)\.gif$
RewriteCond %{REQUEST_URI} !^(.+)\.swf$
RewriteCond %{REQUEST_URI} !^(.+)\.xml$
RewriteCond %{REQUEST_URI} !^(.+)\.ico$
RewriteCond %{REQUEST_URI} !^(.+)\.txt$
RewriteCond %{REQUEST_URI} !^index\.html$
RewriteCond %{REQUEST_URI} !^index\.php$
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^(.+)/$
将 href 从 register.php 更改为 register 像这样
<a href="register"><?php echo strtoupper(t('register', 'register')); ?></a>
我在尝试访问它时遇到的错误是该页面不存在。
【问题讨论】:
-
我们应该怎么知道?你的实际问题是什么?我们不知道您的设置,您知道,但您没有告诉我们。那么我们应该怎么知道呢?
echo strtoupper(t('register', 'register'));是什么?我们不知道那条线是做什么的。你在哪里编写了这两个重写指令?你http服务器的日志文件说什么?你的浏览器说什么?您收到的请求返回的结果是什么?
标签: php html apache .htaccess mod-rewrite