How can I create a shorter alias URL to a longer URL using an .htaccess file?

How can I create a shorter alias URL to a longer URL using an .htaccess file? - .htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about htaccess, url-rewriting, , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :


Using an .htaccess file, I want to make one specific URL have a shorter alias like this:



Original URL:



mydomain.com/index.php?option=com_obrss&task=feed&id=2:rss1klik&format=feed&Itemid=160


Alias to the original URL:



mydomain.com/index.php/rss/rss1klik


Note that both URLs should display the same content.


Solution :

I think the following would work:



RewriteRule ^/index.php/rss/rss1klik$ /index.php?option=com_obrss&task=feed&id=2:rss1klik&format=feed&Itemid=160 [L]


But this may look better:



RewriteRule ^/rss/rss1klik$ /index.php?option=com_obrss&task=feed&id=2:rss1klik&format=feed&Itemid=160 [L]


Then the URL would be http://mydomain.com/rss/rss1klik which is shorter/cleaner still.


Additionally, if you would like to do some further testing, give the htaccess tester tool a try. It allows you to specify a certain URL as well as the rules you would like to include and then shows which rules were tested, which ones met the criteria, and which ones were executed.

Comments

Popular posts from this blog

Rewrite in Mediawiki, remove index.php, .htaccess

.htaccess rewrite wildcard folder paths from host

Using .htaccess to set a cookie and 301 redirect