Php htaccess重定向帮助,请

Php htaccess重定向帮助,请,php,apache,.htaccess,redirect,Php,Apache,.htaccess,Redirect,我以前问过这个问题,但答案似乎不符合要求——它还需要添加一个选项 为用户提供了唯一的URL,即:exampleurl.com/AQ4ILB9 AQ4ILB9是转诊代码 我希望上面的URL(或任何引用URL)显示index.php(htaccess redirect?)的内容 我希望exampleurl.com的非www和www版本(包括example.com/index.php)以以下格式重定向到顶层: 例如,我希望:$\u GET[''u url']在index.php中保存引用id(即:AQ

我以前问过这个问题,但答案似乎不符合要求——它还需要添加一个选项

为用户提供了唯一的URL,即:exampleurl.com/
AQ4ILB9

AQ4ILB9是转诊代码

  • 我希望上面的URL(或任何引用URL)显示index.php(htaccess redirect?)的内容
  • 我希望exampleurl.com的非www和www版本(包括example.com/index.php)以以下格式重定向到顶层:
  • 例如,我希望:
    $\u GET[''u url']
    在index.php中保存引用id(即:
    AQ4ILB9
  • 我如何使用htaccess完成上述3项工作


    谢谢

    将example.com替换为您的域,并将其放入.htaccess文件中:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example.com
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    RewriteRule (.*) /index.php?_url=$1 [L]
    

    你应该做这个把戏!如果已存在
    行中的
    重写引擎,则可能不需要它。

    将example.com替换为您的域,并将其放入.htaccess文件中:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example.com
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    RewriteRule (.*) /index.php?_url=$1 [L]
    
    你应该做这个把戏!如果
    行中已有
    重写引擎,则可能不需要它。

    Q)1和3:

    Q) 2:

    Q) 1和3:

    Q) 2:

    第一部分是301重定向,用于添加www

    第二部分将重写所需内容,但不会重写现有文件/目录

    第一部分是301重定向,用于添加www

    第二部分将重写所需内容,但不会重写现有文件/目录

    RewriteCond %{HTTP_HOST} ^exampleurl.com
    RewriteRule (.*) http://www.exampleurl.com/$1 [R=301,L]
    
    RewriteRule ^/([A-Z0-9]+)$ index.php?_url=$1
    
    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ^example.com
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-z0-9]+)$ /index.php?_url=$1 [NC,L,QSA]