Welcome Guest, Not a member yet? Register   Sign In
[resolved] need help on specific mod_rewrite request
#1

[eluser]Marc Arbour[/eluser]
Hello to all.

I did manage to remove the index.php from my URLs with mod_rewrite.

Here's my .htaccess file:
Code:
RewriteEngine on

# remove dangling index.php in request uri (hint: google, duplicated content)
RewriteRule ^index.php$ / [L,R]

# redirect requests going to www.domain.com to only domain.com
RewriteCond %{HTTP_HOST} ^www.(.+) [NC]
RewriteRule ^(.*)$ http://%1/$1 [L,R,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# I have two additional directories in website structure,
# both of which hold stuff not directly related to kohana (images, raw html templates, css, js...)
# and sometimes I want to enable directory browsing in them.
RewriteCond $1 !^static
RewriteCond $1 !^html
RewriteCond $1 !^index.php [OR]
RewriteRule ^(.*)$ index.php/$1 [L]

Now, Here's the situation: I have a controller/function/parameter/parameter that always looks like
Code:
domain.com/banners/view/1/administrateur

#note the www is removed as well as the index.php
That I'd like to see stripped of it's controller/function part like
Code:
domain.com/1/administrateur
Leaving all other modules/functions work without changes. Even leaving other functions in the banners module as they are now.

I know I can remove part of a URI... Did it with index.php. But can this be done for only 1 module AND 1 function as well? Is there anyone knowledgeable enough with mod_rewrite that can point me in the right direction?

Any pointers will help.

Thanks and best regards.

Marc
#2

[eluser]Dam1an[/eluser]
You don't need .htaccess for that, you need URI routing

If after reading that page you're still not sure, just say, and I'll be more specific Wink
#3

[eluser]Marc Arbour[/eluser]
Thanks Dam1an!!!

I did put
Code:
$route['1/:any'] = "banners/view";
in my routes.php... to get a white page, but I understood that I had to tweak my function to better reflect my new URI segments...

I never got that routes things... Never needed it...

But with your pointer: I am now getting it!

How wonderfull and usefull

Thanks a million.

Best regards.

Marc




Theme © iAndrew 2016 - Forum software by © MyBB