有没有如下使用.htaccess的方法
mydomain.com重定向到mydomain.com/index.php
和
index.php ?u=除mydomain.com以外的所有内容
换句话说,将所有内容(目录、子目录、页面等)转换为一个简单的字符串param,以将变量u传递给index.php
任何帮助都将不胜感激。
发布于 2010-11-21 03:01:45
要将所有内容都发送到index.php:
RewriteEngine On
RewriteCond %{REQUEST_URI} !index.php
RewriteRule (.*) index.php?u=$1 [QSA,L]请注意,这也会向index.php发送对图像、css、javascript等的请求。因为这可能不是你想要的,所以这个可能更合适:
RewriteEngine On
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?u=$1 [QSA,L]它会将所有对不存在的文件和目录的请求发送到index.php。注意:这意味着htdocs文件夹中的任何内容都可以通过它的url访问。因此,这将依赖于htdocs文件夹基本上是空的。
https://stackoverflow.com/questions/4175600
复制相似问题