Php url重写访问问题

Php url重写访问问题,php,.htaccess,Php,.htaccess,我有网址: 我该怎么做 (index.php) (index.php?error=1) 我已经睡过了 RewriteEngine on RewriteRule ^/?rewritedpath/ /myfolder/index.php RewriteRule ^/?rewritedpath/error/([0-9]+)$ /myfolder/index.php?error=$1 但这是行不通的。这里怎么了?谢谢 更新 试试下面的规则 RewriteCond %{REQUEST_FILENA

我有网址:

我该怎么做

(index.php)

(index.php?error=1)

我已经睡过了

RewriteEngine on
RewriteRule ^/?rewritedpath/ /myfolder/index.php
RewriteRule ^/?rewritedpath/error/([0-9]+)$ /myfolder/index.php?error=$1
但这是行不通的。这里怎么了?谢谢

更新


试试下面的规则

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?rewritedpath/ /myfolder/index.php [L]
RewriteRule ^/?rewritedpath/error/([0-9]+)$ /myfolder/index.php?error=$1 [L]

假设您的myfolder位于

/var/www/html/myfolder

  • 确保myfolder中的
    index.php
  • 在/var/www/html/rewritedpath中创建
    .htaccess
    /
  • 在新创建的
    .htaccess
    文件中编写此代码
  • 重新启动引擎

    RewriteRule^(.*)$../myfolder/index.php?params=$1[NC]

  • 在myfolder中的
    index.php
    文件中写入此登录名
  • $get=explode(“/”,$\u get['params'])

    在$get at$get[0]中,我将获得您的密钥错误,$get[1]将获得您的值


    它将解析数组中的所有url参数。

    您的htaccess正常。也许这是一个期望的问题?这不会将URL转换为
    http://127.0.0.1/rewritedpath/
    自动执行。它反过来工作:请求
    http://127.0.0.1/rewritedpath/
    将其重写为
    http://127.0.0.1/myfolder/index.php
    -这意味着您的html现在应该开始瞄准SEO-URL,如果您希望该URL在地址栏中可见。@dognose当我删除第二次重写时,第一次重写起作用,当我删除第一次时,然后第二条规则开始工作,然后试着用
    [L]
    标记它们,但将更具体的规则(第二条)移到顶部。第一条规则包括第二条规则,因此(由于
    [L]
    )第二条规则永远不会被触发。更改顺序。@AbhishekGurjar任何,但不起作用,查看我的更新代码,一切正常吗?啊,非常感谢,这是LocalHost的问题
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/?rewritedpath/ /myfolder/index.php [L]
    RewriteRule ^/?rewritedpath/error/([0-9]+)$ /myfolder/index.php?error=$1 [L]