Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
.htaccess htaccessrewrite、remove.php和redirect为一个规则而不是另一个规则工作_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

.htaccess htaccessrewrite、remove.php和redirect为一个规则而不是另一个规则工作

.htaccess htaccessrewrite、remove.php和redirect为一个规则而不是另一个规则工作,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,我有以下示例URL,有许多可能的参数值 http://www.example.com/area-codes.php?code=0000 http://www.example.com/search.php?number=00000000000 我希望将其分别改写为以下内容 http://www.example.com/area-codes/0000 http://www.example.com/number/00000000000 目前,第二个url正在完全重写和重定向。 但是,最上面的错误会

我有以下示例URL,有许多可能的参数值

http://www.example.com/area-codes.php?code=0000
http://www.example.com/search.php?number=00000000000
我希望将其分别改写为以下内容

http://www.example.com/area-codes/0000
http://www.example.com/number/00000000000
目前,第二个url正在完全重写和重定向。 但是,最上面的错误会导致内部服务器错误

这是我的访问权限

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_URI} \.(jpg|css|js|gif|png)$ [NC]
RewriteRule ^ - [L]

#unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [R=301,L]

#resolve .php file for extensionless php urls
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]

#redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)*[^.#?\ ]+\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(([^/]+/)*[^.]+)\.php /$1 [R=301,L]    

RewriteRule ^area-codes/([^/]*)$ /area-codes.php?code=$1 [L,QSA]
RewriteRule ^number/([^/]*)$ /search.php?number=$1 [L,QSA]

我假设我的标志出了问题?

注释掉了这两行,它就成功了

#resolve .php file for extensionless php urls
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]