Magento custom module with custom url with add .html extension - magento

I have created an module and its front end name is test .
Now i want a URL like
www.exmpale.com/test/red.html (original structure is like 'test/index/index/valuid/1/').
www.exmpale.com/test/green.html (original URL is like 'test/index/index/valueid/3/').
Wheremy crontroller is indexCrontroller and action is indexAction and where red /green ,will coming dynamic from a table.
The Table is structure is like
tab_id value
1 red
2 blue
3 green
Please help me.

You need to implement the Router for these URLs. please follow this link
http://inchoo.net/ecommerce/magento/custom-router-in-magento/

Use 301 redirect in htaccess file as follows:
Paste the below code in your .htaccess file in root folder:
Redirect 301 /test/index/index/valuid/1/ www.exmpale.com/test/red.html
Redirect 301 /test/index/index/valuid/3/ www.exmpale.com/test/green.html

Related

Why Joomla shows contents with any URL?

I found a bug in my Joomla 3.6.4 site when I searched in google for test purpose.
For example I have a content with ID 34 and alias myalias
Now Unexpectedly all of below URLs load my content:
http://example.com/test-test-test/34-myalias
http://example.com/mytest/34-myalias
http://example.com/hellowwwwwwwwwwwww/34-myalias
http://example.com/aything/34-myalias
and so on.
This is not TRUE at all!! The content must be loaded just in my predefined menu item. For example I assign a new Menu Item in Menu Manager like definedmenu witch shows content 34. So below URL should works only:
http://example.com/definedmenu/34-myalias
What is the problem. It's bad for my website SEO...
Thanks.
http://example.com/index.php?option=com_content&view=article&id=34&name=ram&age=30
here
http://example.com/index.php is a base url
and
option=com_content&view=article&id=34&name=ram&age=30
these are input variables
when we change url to SEO url
http://example.com/index.php/content/article/34/ram/30
so
http://example.com/test-test-test/34-myalias
http://example.com/mytest/34-myalias
http://example.com/hellowwwwwwwwwwwww/34-myalias
http://example.com/aything/34-myalias
"test-test-test" treat as input variable
"mytest" treat as input variable
but each component have some restriction in component route, in content "id-alias" format so "34-myalias" but here id is important
http://example.com/test-test-test/34-myaliasdfdfdfd it will work
http://example.com/test-test-test/34-sdsdsdmyalias it will work
but
http://example.com/test-test-test/sdsd34-myalias it will not work
This is why many people turn to SEO components like
RSSEO! https://www.rsjoomla.com/joomla-extensions/joomla-seo.html
or
sh404SEF https://weeblr.com/joomla-seo-analytics-security/sh404sef

redirect image to different image htaccess

I have tried cpanel redirect but it is not specific. I made a change to my site where anyone using a now old image needs to show a new image. I would like to redirect the link to the old image to the url to the new image.
I have an image
http://mysite.com/images/image.png
When the image is called I want to show
http://mysite.com/images/image.gif
What do I add to htaccess to create this specific rule?
Note that image1 is a png and I am replacing it with a gif so I cant just overwrite with the new image. This is why I am looking for a redirect solution.
EDIT: I can give the image the same name, it will just have different extension.
EDIT 2: change to show image would have the same name, different extension.
A simple URL rewrite should do the trick!
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^images/([a-zA-Z0-9]+).png$ images/$1.gif
Whatever is entered here '([a-zA-Z]+)' will be entered here '$1'. Hope that makes sence.
Let me know how you get on!
(Note: there is no rewrite condition to check if the file exists because you want the url rewritten whether there is a file there or not)
Edit:
Probably best to put a .htaccess in the images directory, in this case you can miss out the file paths as you are already in the directory.
If you're looking to replace this one specific image1.png to image2.gif, then this rule should work:
RewriteRule ^images/image1.png$ images/image2.gif [NC,L]
If you're looking for something more general-purpose, then it depends on your image naming.

PyroCMS: How Do I Create a multi Segment URL ?

I want my url to be like this:
mysite.com/categories/roofing
I can achieve this by creating a new navigation group called categories and make roofing a child BUT I do not want a new Navigation group. I want to be able to call a specific function by identifying segment 1 while still having the url include segment 2.
I tried doing it in "Page Types" but it will not allow you to create a multi segment slug.
I have the stream module if that helps.
Many Thanks !!
This is actually really simple and there are a few ways to do it. The simple way would be to create a page with the slug categories (you can redirect this page using routing later if you don't want it to exist), and then create a page with the slug roofing. Finally, in the pages section of the admin, drag roofing under categories as a child.
This can also be done using routing. You would create a routes.php file with the config folder with the following:
$route['categories/(:any)'] = '$1';

URL rewriting, using friendly urls

Currently urls are like this http://example.com/?p=2, so if I link to another page in my site, it will be
A database contains a list of pages, with 3 columns, id, title and content. So for example the page with id 2 has a title of foo.
I want the user to be able to enter the url: http://example.com/foo and have the user see what is on http://example.com/?p=2. So I will be able to link to pages like: but the URL in the address bar will remain the friendly (foo) version.
I'm not sure if this is the right syntax, but logically you should have in your .htaccess file something like this:
RewriteEngine on
RewriteRule ^(.*)$ index.php?title=$1
then inside index.php you GET title and do what you want with it.

Yii Url Rewrites

I got static pages to rewrite by modifying the urlManager like this.. 'login'=>'user/login'
which allows www.site.com/user/login.php to display as www.site.com/login.php
The goal is to be able to take user/ out of everything under the user directory.
Allright to fill in the blanks here...a solution
'<_a:(login|index|update|etc)>' => 'user/<_a>',

Resources