flaab Posted October 29, 2007 Share Posted October 29, 2007 Hi folks :-) My problem is dumb but it's driving me nuts. I have an index.php that receives urls like these - www.domainname.com/index.php?foo/fooaction/parameters - www.domainname.com/index.php?articles/view/5 - www.domainname.com/index.php?contact The part behind ? is called QUERY_STRING in Apache and Php and it's JUST ONE string ("foo/foo2/foo3/whatever") I would like to redirect www.domainname.com/controller/action/parameter to www.domainname.com/index.php?controller/action/parameter so the "index.php?" part does not have to appear in the url. I've played around for a long time but i haven't been able to get it. Which is the correct RewriteRule for that? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
trq Posted October 29, 2007 Share Posted October 29, 2007 Try... RewriteRule ^(.*)$ index.php?$1 [L] Quote Link to comment Share on other sites More sharing options...
flaab Posted October 29, 2007 Author Share Posted October 29, 2007 I've tried and it does not work =) Here's my .htacess Options -Indexes Options +FollowSymLinks RewriteEngine on RewriteRule ^(.*)$ index.php?$1 [L] The problem is that www.foo.com/foo/foo1/foo2 should be pointing to www.foo.com/index.php?foo/foo1/foo2. I've tried with this one also Options -Indexes Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteRule ^(.*)$ index.php?$1 [L] But it does not work either :-) thanks anyway i'll keep trying Quote Link to comment Share on other sites More sharing options...
trq Posted October 29, 2007 Share Posted October 29, 2007 How are you trying to retrieve these values within index.php? Quote Link to comment Share on other sites More sharing options...
flaab Posted October 29, 2007 Author Share Posted October 29, 2007 Hi :-) The index.php is called with a large query string. Example: index.php?controller/action/param1/../param10 The last url is the same as www.domain.com/?controller/action/param1/../param10 Then in the php code $_SERVER['QUERY_STRING'] is "controller/action/param1/../param10". Then I explode the query string and call the requested controller executing the requested action and passing the given parameters. I just want to get rid of the ugly '?' char in the Url so it can be called like this www.domain.com/controller/action/param1/../param10 I will keep on trying :-) thanks Quote Link to comment Share on other sites More sharing options...
flaab Posted October 30, 2007 Author Share Posted October 30, 2007 I got it! Like this <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^([^.]+)/?$ index.php?$1 [L] </IfModule> But now my Css links are broken and some images as well. How can I link them? Quote Link to comment Share on other sites More sharing options...
hackerkts Posted November 1, 2007 Share Posted November 1, 2007 I got it! Like this <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^([^.]+)/?$ index.php?$1 [L] </IfModule> But now my Css links are broken and some images as well. How can I link them? You will have to use full URLs. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.