Jump to content

[mod_rewrite] Simple RewriteRule driving me nuts


flaab

Recommended Posts

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.

 

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.