如何使用.htaccess文件进行内部重定向?

2cmtqfgy  于 2022-11-16  发布在  其他
关注(0)|答案(1)|浏览(99)

我有网址

https://example.net/app/ref/user/u123456

https://example.net/app/ref/user/u123456/

需要将两个URL重定向到https://example.net/app/ref/user/index.php?referral=u123456
如何用一个.htaccess文件来做呢?很不幸,我做不到,所以我请求你的帮助。
UPD:现在me.htaccess和index.php在同一个目录中:

<IfModule mod_rewrite.c>
  RewriteEngine on
</IfModule>
AddType application/x-httpd-php .html
<Files 403.shtml>
order allow,deny
allow from all
</Files>
q8l4jmvw

q8l4jmvw1#

使用显示的示例,请尝试以下htaccess规则文件。请确保将.htaccess规则文件保存在根文件夹中;以及应用程序文件夹。
请确保在测试URL之前清除浏览器缓存。

RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*/[^/]*/[^/]*)/([^/]*)/?$ $1/index.php?referral=$2 [QSA,L]

相关问题