我在htaccess文件中有这段代码:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-/_]+)/?$ http://subdomain.example.com/index.php?id=$1 [L,QSA]
但每次我去http://subdomain.example.com/test/test
应该解决:
http://subdomain.example.com/index.php?id=test/test
它确实如此,但它将我的URL更改为上面的URL并且不保留原始URL
答案 0 :(得分:1)
从目标网址中删除http://
:
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} =subdomain.example.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?id=$1 [L,QSA]
我还在RewriteRule
修正了你的正则表达式。