So if the user types mydomain.com/dashboard, the document the server actually sends them is /launch.php?i=/dashboard.
因此,如果用户键入mydomain.com/dashboard,则服务器实际发送的文档为/launch.php?i=/dashboard。
The one caveat is that I would like to leave requests for
一个警告是,我想留下请求
- /flags
- /people
- /posters
- /css
- /icons
- /images
- /libraries
- /patterns
alone, and they should request the actual folder.
单独,他们应该请求实际的文件夹。
How would I create such a mod_rewrite?
我该如何创建这样的mod_rewrite?
1 个解决方案
#1
5
This is the .htaccess file for the CakePHP Framework.
这是CakePHP框架的.htaccess文件。
Please replace the index.php and ?url= to fit your needs.
请替换index.php和?url =以满足您的需求。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
The "!-d" tells Apache to follow existing folders and "!-f" to follow existing files.
“!-d”告诉Apache遵循现有文件夹,“! - f”跟随现有文件。
Everything else is channelled through index.php
其他一切都是通过index.php引导的
As suggested in a comment, you have to be aware that if it's not working it could be because mod_rewrite is not enabled and you'll not get an error stating that fact, you'll probably only have a HTTP 404.
正如评论中所建议的那样,你必须要知道,如果它不起作用,可能是因为mod_rewrite没有启用,你不会得到一个错误说明这个事实,你可能只有一个HTTP 404。
#1
5
This is the .htaccess file for the CakePHP Framework.
这是CakePHP框架的.htaccess文件。
Please replace the index.php and ?url= to fit your needs.
请替换index.php和?url =以满足您的需求。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
The "!-d" tells Apache to follow existing folders and "!-f" to follow existing files.
“!-d”告诉Apache遵循现有文件夹,“! - f”跟随现有文件。
Everything else is channelled through index.php
其他一切都是通过index.php引导的
As suggested in a comment, you have to be aware that if it's not working it could be because mod_rewrite is not enabled and you'll not get an error stating that fact, you'll probably only have a HTTP 404.
正如评论中所建议的那样,你必须要知道,如果它不起作用,可能是因为mod_rewrite没有启用,你不会得到一个错误说明这个事实,你可能只有一个HTTP 404。