Php url重写访问问题
我有网址: 我该怎么做 (index.php) (index.php?error=1) 我已经睡过了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
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
index.php
.htaccess
/.htaccess
文件中编写此代码重新启动引擎
RewriteRule^(.*)$../myfolder/index.php?params=$1[NC]
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]