0

I have php wesite using following url, http://example.com/subfolder/category

Now, i want to remove "subfolder" from url using php, but there can be multiple categories which can come and i dont want to write every category condition in .htaccess file?

Thus it will be like, if someone calls url like http://example.com/category, it will be redirected to file in "subfolder" but "subfolder" wont appear in url like this, {host_name}/category. Can this be done?

Example: {domain}/subfolder/category => {domain}/category

Thus subfolder will be removed.

Please help. Thanks in advance.

Arbflow
  • 1
  • 3
  • can you add more specific examples on how the redirection is intended? – Stoic Nov 29 '13 at 09:51
  • Do you have any framework in your case? if there is "routes" will solve your problem. – Eric T Nov 29 '13 at 09:55
  • No framework, just smarty templating is used. So cannot use routes. – Arbflow Nov 29 '13 at 10:10
  • One way or another, you'll have either to redirect all the traffic to your php (with .htaccess), or configure .htaccess to rewrite the url I think. You could start by reading this: http://stackoverflow.com/questions/1316040/how-to-implement-url-routing-in-php-im-a-newcomer-to-know-this-concept-help-me – achedeuzot Nov 29 '13 at 10:13

1 Answers1

0

In the www_root .htaccess, put…

RewriteEngine On
RewriteBase /
RewriteRule ^subfolder\/(.*) $1

I think that should do it.

Dan Goodspeed
  • 3,484
  • 4
  • 26
  • 35
  • I am unable to get this work. I have url like example.com/subfolder/category and need to convert it to example.com/category but it should call the file in subfolder. – Arbflow Nov 29 '13 at 12:03
  • Did you change "subfolder" to whatever it is that your subfolder is called? – Dan Goodspeed Nov 30 '13 at 00:37
  • Thanks Dan for your help. But i have followed the process mentioned in this [post](http://stackoverflow.com/questions/7189803/url-rewriting-php-templating-and-the-get-array)! – Arbflow Nov 30 '13 at 07:28