URL重写HTACCESS问题



我有url:

http://127.0.0.1/myfolder/index.php

http://127.0.0.1/myfolder/index.php?error = 1 ...

我该如何制作

http://127.0.0.1/rewritedpath/(index.php(

http://127.0.0.1/rewritedpath/error/1(index.php?error = 1(

我已经ried

RewriteEngine on
RewriteRule ^/?rewritedpath/ /myfolder/index.php
RewriteRule ^/?rewritedpath/error/([0-9]+)$ /myfolder/index.php?error=$1

但这不起作用。这里怎么了?谢谢

更新


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

尝试以下规则,

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]

假设您位于

/var/www/html/myFolder

  1. 确保MyFolder中的index.php
  2. 在/var/www/html/rewritedpath/
  3. 中创建.htaccess
  4. 在您新创建的.htaccess文件中写入此代码

RewriteEngine On

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

  1. 在位于myFolder的index.php文件中写下此登录

$get = explode("/",$_GET['params']);

in $ in $ get in $ get [0] youi将遇到密钥错误,$ get [1]您将获得您的价值。

它将在数组中解析所有URL参数。

最新更新