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.

4
  • can you add more specific examples on how the redirection is intended? Commented Nov 29, 2013 at 9:51
  • Do you have any framework in your case? if there is "routes" will solve your problem. Commented Nov 29, 2013 at 9:55
  • No framework, just smarty templating is used. So cannot use routes. Commented Nov 29, 2013 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: stackoverflow.com/questions/1316040/… Commented Nov 29, 2013 at 10:13

1 Answer 1

0

In the www_root .htaccess, put…

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

I think that should do it.

Sign up to request clarification or add additional context in comments.

3 Comments

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.
Did you change "subfolder" to whatever it is that your subfolder is called?
Thanks Dan for your help. But i have followed the process mentioned in this post!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.