Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.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
如何在CGI上使用PHP重写Url_Php_Mod Rewrite_Url Rewriting_Fastcgi_Url Rewrite Module - Fatal编程技术网

如何在CGI上使用PHP重写Url

如何在CGI上使用PHP重写Url,php,mod-rewrite,url-rewriting,fastcgi,url-rewrite-module,Php,Mod Rewrite,Url Rewriting,Fastcgi,Url Rewrite Module,我更熟悉mod_rewrite,我使用apache对php网站进行url重写。但是我的php是在cgi上运行的。如何在cgi上使用php在.htaccess中重写Url 我在CGI上使用1和1的Linux VPS和php 我使用下面的代码从url中删除.php RewriteEngine On # browser requests PHP RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php RewriteRule ^/?(.*)\.ph

我更熟悉mod_rewrite,我使用apache对php网站进行url重写。但是我的php是在cgi上运行的。如何在cgi上使用php在.htaccess中重写Url

我在CGI上使用1和1的Linux VPS和php 我使用下面的代码从url中删除.php

RewriteEngine On

# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]

# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]
但它说,现在还没有发现以下错误

它用于About.php
对不起,我忘记提了

<IfModule mod_rewrite.c>
</IfModule>

下面是正确的代码

<IfModule mod_rewrite.c>
RewriteEngine On

# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]



# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]
</IfModule>

重新启动发动机
#浏览器请求PHP
重写cond%{THE_REQUEST}^[A-Z]{3,9}\/([^\]+)\.php
重写规则^/?(.*)\.php$/$1[L,R=301]
#检查请求是否针对PHP文件:
重写cond%{REQUEST_FILENAME}\.php-f
重写规则^/?(.*)$/$1.php[L]

您使用的是什么web服务器?Nginx?根据web服务器的不同,您可能需要查看如何为特定服务器创建重写。大多数人无法读取htaccess文件。(据我所知,这些只是Apache)。我使用的是1和1的Linux VPS,这对我没有帮助。不知道那些副总裁在用什么。@MagnusEriksson你能告诉我你还有什么其他信息吗need@MagnusEriksson我正在为我的问题添加更多信息,这可能会对您有所帮助
<IfModule mod_rewrite.c>
RewriteEngine On

# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]



# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]
</IfModule>