简体   繁体   English

mod_rewrite和{QUERY_STRING}

[英]mod_rewrite and {QUERY_STRING}

Changed my url from 更改了我的网址

http://www.website.com/b.php?n=45&t=example

to this 对此

http://www.website.com/45/example

by using this mod_rewrite 通过使用此mod_rewrite

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?([^/]+)/(.*) /b.php?n=$1&b=$2 [L,QSA]

How do I get my query strings to still work because I want to use $_GET 我如何使用$ _GET使查询字符串仍然有效

echo '<img src="gifs/' . $_GET["t"] . '/' . $_GET["n"] . '.gif">';

You can use the following .htaccess code for sending the full url to the b.php file and there you can split the url using the explode function and can get the query strings separately 您可以使用以下.htaccess代码将完整的url发送到b.php文件,在这里您可以使用explode函数拆分url,并可以分别获取查询字符串

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/* b.php?url=%{REQUEST_URI} [L,NC,QSA]

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

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