What is Mod_Rewrite?
Simply put, mod_rewrite is an Apache module that let’s you rewrite urls based on rules you define.
- Directing all traffic from multiple domain names to one domain
- Directing all traffic from www and non-www to one location
- Blocking traffic from specific websites
- Blocking spammy searchbots and offline browsers from spidering your site and eating your bandwidth
- Mask file extensions
- Preventing image hotlinking (other web pages linking to images on your server)
Cake PHP URLs can be made SEO friendly by using the overwrite rule and modifying the htacess file of the root folder as shown below:
The below example of URL Rewrites for the site has n level menus,
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^([^/]+html)$ app/webroot/controller_name/function_name/$1 [L]
RewriteRule ^[^/]+/([^/]+html)$ app/webroot/controller_name/function_name/$1 [L]
RewriteRule ^[^/]+/[^/]+/([^/]+html)$ app/webroot/controller_name/function_name/$1 [L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule> Note:
Running URL Rewrite sucessfully, we need to enable the mod_rewrite.so in the httd.conf of Apache Server.
LoadModule rewrite_module modules/mod_rewrite.so




CakePHP biblioteka #1 « Labs said,
March 18, 2009 at 12:59 pm
[...] Šiek tiek SEO, “pagražinant” nuorodas su mod_rewrite 2009.03.18 Developing’as cache, CakePHP, jquery, [...]
rafeekphp said,
March 19, 2009 at 12:51 pm
Thanks
adding my blog on your site.
Jipson said,
May 13, 2010 at 12:12 pm
Hello,
I have a cakephp site like
mysite.com/admins/login/, where admins_controller is my controller name. How I can access the same by mysite.com/admin/login/
Thanks and Regards,
Jipson
rafeekphp said,
July 9, 2010 at 6:22 am
Hi,
In your route.php you have to mention controller,view and action name in order to access the admin login section.
We have already default route for client section with that you have to add new route to point the admin also.
Thanks
Rafeek