Mod_rewrite in Cakephp

Asked

Viewed 102 times

0

I need to change all the URL’s of a website once it’s done.

The current URL is in the following structure: www.meudominio.com.br/website/ And I would like it to be removed from all the internal urls, the website folder, without having to mess with the file structure.

Another amendment is more delicate:

www.meudominio.com.br/site/Produtos/view/13

for

www.meudominio.com.br/nome-do-produto-ou-da-noticia

I studied and tested some codes from . HTACCESS’s mod_rewrite but I couldn’t solve the situation. I also tried Cakephp’s Routes:: unsuccessfully.

.HTACCESS:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^site/Home http://www.meudominio.com.br/ [L]
RewriteRule ^site/([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+) http://www.meudominio.com.br/ [L]
RewriteRule ^([a-zA-Z0-9-]+)/([a-zA-Z0-9-]+).*$ http://www.meudominio.com.br/$2 [L]
  • First thing, you don’t need to leave your website in the folder site. Second thing, post the attempts you made on cake Routes to see if there’s anything you’ve done wrong. Third thing, if possible describe the behavior that occurred in your attempts.

  • My HTACCESS: Options +Followsymlinks Rewriteengine On Rewriterule site/Home http://www.meudominio.com.br/ [L] Rewriterule site/([a-za-Z0-9-]+)/([a-za-Z0-9-]+) http://www.meudominio.com.br/ [L] Rewriterule ([a-za-Z0-9-]+)/([a-za-Z0-9-]+)/([a-za-Z0-9-9-]+). *$ http://www.meudominio.com.br/$2 [L]

  • There are other folders in your public_html that prevent you from leaving the cake files in the root folder? What were your attempts using cakephp routes?

  • No folder, but my fear is to disfigure something on the site.

  • As for the routes, I tried to insert a Routes::connect into the Routes file, and generate the link in the view via $this->HTML->link - but it looks like it redirected all the structure pages to the specified controller, not just the controller. Router::connect('/:title', array('controller' => 'Namidia', 'action' => 'view'), array( 'pass' => array('title'), 'id' => '[a-za-Z0-9-]+') );

  • If there are no other folders there is no problem in moving your files to root folder. You have already read on cake documentation how to deal with Routes?

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.