Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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 清理URL时出现问题。htaccess-找不到页面_Php_.htaccess_Http Status Code 404_Clean Urls - Fatal编程技术网

Php 清理URL时出现问题。htaccess-找不到页面

Php 清理URL时出现问题。htaccess-找不到页面,php,.htaccess,http-status-code-404,clean-urls,Php,.htaccess,Http Status Code 404,Clean Urls,我试图用php创建干净的URL,但我遇到了一些错误。希望有人能帮忙 我的.htaccess如下所示: # Use PHP5 Single php.ini as default AddHandler application/x-httpd-php5s .php # this is the initialization # For security reasons, Option followsymlinks cannot be overridden. #Options +Follo

我试图用php创建干净的URL,但我遇到了一些错误。希望有人能帮忙

我的.htaccess如下所示:

# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
# this is the initialization
# For security reasons, Option followsymlinks cannot be overridden.
#Options         +FollowSymLinks
Options +SymLinksIfOwnerMatch
RewriteEngine   On
RewriteBase     /
# these are the rewrite conditions
RewriteCond     %{REQUEST_FILENAME}     !-f
RewriteCond     %{REQUEST_FILENAME}     !-d
# and finally, the rewrite rules
RewriteRule     ^([a-zA-Z0-9\-]+)/?$    /price/index.php?var1=$1 [L,QSA]
RewriteRule     ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$   /price/index.php?var1=$1&var2=$2 [L,QSA]
RewriteRule     ^([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$    /price/index.php?var1=$1&var2=$2&var3=$3 [L,QSA]
实际上,我正在尝试在子文件夹
price/
中创建干净的URL

当我输入:
mydomain.com/price/param1
时,它工作得非常完美,实际上它将我重定向到
mydomain.com/price/index.php?var1=param1

但是,当我试图继续研究更多的变量时,我就遇到了问题。当我尝试访问
mydomain.com/price/param1/param2
时,我没有被重定向,出现404错误

有什么想法吗?提前感谢。

试试:

# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php

<IfModule mod_rewrite.c>
    # This is the initialization
    # For security reasons, Option followsymlinks cannot be overridden.
    #Options +FollowSymLinks
    Options +SymLinksIfOwnerMatch
    RewriteEngine On
    RewriteBase /

    # /price/var1/var2/var3
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^price/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1&var2=$2&var3=$3 [L,QSA]

    # /price/var1/var2
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^price/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1&var2=$2 [L,QSA]

    # /price/var1
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^price/([a-zA-Z0-9\-]+)/?$ /price/index.php?var1=$1 [L,QSA]
</IfModule>
#使用PHP5 Single php.ini作为默认值
AddHandler应用程序/x-httpd-php5s.php
#这是初始化
#出于安全原因,无法覆盖选项followsymlinks。
#选项+FollowSymLinks
选项+符号链接所有者匹配
重新启动发动机
重写基/
#/price/var1/var2/var3
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^price/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$/price/index.php?var1=$1&var2=$2&var3=$3[L,QSA]
#/price/var1/var2
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^price/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$/price/index.php?var1=$1&var2=$2[L,QSA]
#/price/var1
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^price/([a-zA-Z0-9\-]+)/?$/price/index.php?var1=$1[L,QSA]
试试:

#使用PHP5 Single php.ini作为默认值
AddHandler应用程序/x-httpd-php5s.php
#这是初始化
#出于安全原因,无法覆盖选项followsymlinks。
#选项+FollowSymLinks
选项+符号链接所有者匹配
重新启动发动机
重写基/
#/price/var1/var2/var3
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^price/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$/price/index.php?var1=$1&var2=$2&var3=$3[L,QSA]
#/price/var1/var2
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^price/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$/price/index.php?var1=$1&var2=$2[L,QSA]
#/price/var1
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则^price/([a-zA-Z0-9\-]+)/?$/price/index.php?var1=$1[L,QSA]

此.htaccess位于何处--是在网站根文件夹中还是在/price/.htaccess?这两个
RewriteCond
仅适用于紧随其后的单个规则。此.htaccess位于根文件夹中,但这不是问题所在。mootinator,这是什么意思?@Dan Stern:这意味着你拥有上面的.htaccess代码,如果你访问了
/price/var1/var2
,并且有一些目录的层次结构与你的url相同,那么重写就会开始,你将无法访问这些目录。这就是条件存在的原因,
-f
-d
表示仅当请求所在位置不存在文件或目录时才进行重写。此.htaccess位于何处--在网站根文件夹中还是在/price/.htaccess中?这两个
RewriteCond
仅适用于紧随其后的单个规则。此.htaccess位于根文件夹中,但这不是问题所在。mootinator,这是什么意思?@Dan Stern:这意味着你拥有上面的.htaccess代码,如果你访问了
/price/var1/var2
,并且有一些目录的层次结构与你的url相同,那么重写就会开始,你将无法访问这些目录。这就是条件存在的原因,
-f
-d
表示仅当请求所在位置不存在文件或目录时才重写。