A trixy Mod_Rewrite
I have a site that I need to do a trixy mod_rewrite for! Here is the situation. I have domain.com I am using Symfony as my Framework and I need to be able to hit a module with a nothing but 开发者_如何学运维an ID in the main domain. Example for clarification:
example:
http://www.domain.com/web/index.php/module/show/id/1
Here is my url to the page I am interested in
http://www.domain.com/1
I want this page to go to the above page
*Note: ID can be a number OR a string i.e. /1 or /bobsHope
This issue I see with this is how do allow for any id/string and still have the entire rest of my site work. The possible solution I see here is that every other page always starts with /web
Any assistance is greatly appreciated.
Firstly, you're best off if you can set /web
as your DocumentRoot, either using a symlink or via httpd.conf
If you can do that, it's just a matter of creating a routing rule, e.g.
a_basic_route:
url: /:id
param: { module: somemodule, action: someaction }
If you cannot, then I believe the following in your .htaccess will work together with the above routing rule:
RewriteRule ^(.*)$ web/index.php/$1 [L,QSA]
精彩评论