Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 单页.htaccess重写_Php_.htaccess_Mod Rewrite_Rewrite - Fatal编程技术网

Php 单页.htaccess重写

Php 单页.htaccess重写,php,.htaccess,mod-rewrite,rewrite,Php,.htaccess,Mod Rewrite,Rewrite,我想使用htaccessrewrite来显示没有扩展名的单个页面 到 这不管用吗?它什么也不做 我也试过一个普通的,但也不起作用: RewriteEngine on RewriteRule ^(.*)/$ $1.php 是否启用了“重写”模块?也许可以尝试检查以斜杠结尾的URL <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^account\/\?$ /account.php [L] </IfModule&g

我想使用htaccessrewrite来显示没有扩展名的单个页面

这不管用吗?它什么也不做

我也试过一个普通的,但也不起作用:

RewriteEngine on
RewriteRule ^(.*)/$ $1.php

是否启用了“重写”模块?也许可以尝试检查以斜杠结尾的URL

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^account\/\?$ /account.php [L]
</IfModule>

重新启动发动机
重写规则^account\/\?$/account.php[L]

我的建议是使用动态规则,而不是静态规则:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1.php [L]
这样,任何页面都将引用任何PHP脚本

例如:

将加载

将加载

但是,如果您确实喜欢使用静态重写规则,则可以使用以下规则:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^index index.php [L]
我想指定,如果您计划对位于子文件夹内的脚本使用这些重写规则,如


然后最好在您启动
RewriteEngine

之后添加一个
RewriteBase
,我仍然会得到/account和/account的404/
RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule ^index index.php [L]