tags:

views:

26

answers:

2

I would like to create a mod rewrite in my htaccess file that will can change this:

mydomain.com/abCdE

to this: mydomain.com/controller/view/parameter/abCdE

Thanks in advance!

P.S. I'm using Zend Framework

Stefano

A: 

You can use mod_rewrite to redirect ALL (or almost all) requests to one PHP file, and make it do the job:

RewriteEngine on  
RewriteRule (.*) /parser.php?q=$1

If you want to leave some pages, you may put conditions:

RewriteEngine on

# Makes root of your site not to redirect to parser:
RewriteCond %{REQUEST_URI} !^/$            

# Same for mypage.php
RewriteCond %{REQUEST_URI} !^/mypage.php$

# testdir and all files in it are not redirected to parser
RewriteCond %{REQUEST_URI} !^/testdir/

RewriteRule (.*) /controller/view/parameter$1
BlaXpirit
A: 

I've created this sort of thing in the past. This is what you want:

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule (.*) /parser.php?q=$1 [L,QSA]

That way every single existing file and directory on your website will still work, and every thing else (*including any extra _GET parameters!) will be passed too.

If you're putting this inside an .htaccess file, change the RewriteRule to

    RewriteRule (.*) parser.php?q=$1 [L,QSA]

This should thoroughly answer your question.

hopeseekr