我正在尝试将子域(非REDIRECT)重写为 $_GET 参数,如下所示:
Desired result:
http://go.example.bz/link/abcde -> http://example.bz/go/link?id=abcde
or
http://go.example.bz/hrm/employee/8 -> http://example.bz/go/hrm/employee?id=8
目前有什么工作:
http://example.bz/go/link/abcde -> http://example.bz/go/link?id=abcde
and
http://example.bz/go/hrm/employee/8 -> http://example.bz/go/hrm/employee?id=8
使用root中的.htaccess:
RewriteEngine On
RewriteRule ^go/link.php/([^/\.]+)/?$ go/link.php?id=$1 [L]
RewriteRule ^go/hrm/employee.php/([^/\.]+)/?$ go/hrm/employee.php?parameter=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]
AddCharset UTF-8 .php
Options -Indexes
这就是我重定向子域的方式:
<VirtualHost *:80>
Servername go.example.bz DocumentRoot /var/www/go
</VirtualHost>
I do not want to redirect 到 - >目的地,而不是保留http://go.example.bz/link/abcde网址但是有/ link的结果?abcde
4 回答
我想我的问题来自于不从子域URL中删除.php扩展名,我在这里找到了答案https://css-tricks.com/forums/topic/remove-php-extension-from-subdomain-urls/然后我交替使用我的RewriteRules:
您可以在root .htaccess中使用此规则:
这有用吗: