Marcel Vuijk Marcel Vuijk - 1 year ago 90
PHP Question

How to make a clean URL of this (htaccess URL rewrite)

I use a support system and I want to rewrite the URLs to make them more SEO friendly and better readable. I have very basic understanding of .htaccess rewrite rules / regex and I tried a hundred things, but could not get it working.

The support system is installed on this URL:

http://www.example.com/help/


The code is generating this URL for every article in the KB:

http://www.example.com/help/index.php?/selfhelp/view-article/article-1


The code is generating this URL for the category overview within the KB:

http://www.example.com/hulp/index.php?/selfhelp/categories


How can I rewrite those URLs to something readable and SEO friendly like:

http://www.example.com/help/article/article-1


And for categories:

http://www.example.com/hulp/categories


If this is even possible? And if so, how can I do this using .htaccess.

Answer Source

Well you can make the friendly URLs work like this:

RewriteRule ^help/article/(.+)$ help/index.php?/selfhelp/view-article/$1
RewriteRule ^help/categories$ help/index.php?/selfhelp/categories
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download