Friday 15 April 2011

apache - Zend framework2 URL Rewriting -



apache - Zend framework2 URL Rewriting -

the url user profile in zf2 application is:

http:/mywebsite/profile/index/index/457/

here 457 id of user(say rogger_federer).

i want url this(by fetching username database using id in url)

http:/mywebsite/profile/rogger_federer

my htaccess file is

rewriteengine on # next rule tells apache if requested filename # exists, serve it. rewritecond %{request_filename} -s [or] rewritecond %{request_filename} -l [or] rewritecond %{request_filename} -d rewriterule ^.*$ - [nc,l] # next rewrites other queries index.php. # status ensures if using apache aliases # mass virtual hosting, base of operations path prepended # allow proper resolution of index.php file; work # in non-aliased environments well, providing safe, one-size # fits solution. rewritecond %{request_uri}::$1 ^(/.+)(.+)::\2$ rewriterule ^(.*) - [e=base:%1] rewriterule ^(.*)$ %{env:base}index.php [nc,l]

what changes need in .htaccess file?

please help .i'm new zend , dont have much knowledge of htaccess , patterns.

thanks in advance.

this not can in .htaccess, because need db.

what's happening when receive request is going through htaccess first, , in router. routing configuration in module configuration file.

what have alter route profile/index/index/457/ (probably default route, quote config file more information) accepting profile/rogger_federer (that segment route /profile/:username constraint username:([az-az_]*) , no default. route has send controller lookup in db , fetch user based on username.

you need create sure username has unique constraint, , sluggable/slugged (sanitized url).

apache .htaccess url-rewriting zend-framework2

No comments:

Post a Comment