简体   繁体   English

htaccess重写规则,无需更改URL

[英]htaccess rewrite rule without changing URL

I have this code in my htaccess file: 我的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]

but everytime i go to something like http://subdomain.example.com/test/test 但是每次我去像http://subdomain.example.com/test/test东西

it should resolve to: 它应该解决:

http://subdomain.example.com/index.php?id=test/test

which it does, but its changing my URL to be the above and its not keeping the original URL 可以,但是将我的网址更改为上述网址,并且不保留原始网址

Remove http:// from your target URL: 从目标网址中删除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]

I have also corrected your regex in RewriteRule . 我还纠正了RewriteRule的正则表达式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM