Is it possible for htaccess to interpret a file as a directory (subdomain)?

Asked

Viewed 93 times

0

I have several files with various contents, like: ajuda.php? go=Faq, ajuda.php? go=form, etc. Wanted something like: help.site.com/Faq, help.site.com/form, etc. It would be possible via htaccess for the help.php file to be interpreted as directory?

  • @Bacco is that when creating a subdomain the server understands as folder, so.

  • Easier for you to explain what you want to happen. I couldn’t see the relationship of that last comment to the question. What exactly do you want to do? Subdomain has nothing to do with either PHP or . htaccess directly.

  • @Bacco look good. Let’s forget php and just focus on htaccess. I already have a lot done (codes) and wanted to take advantage, like: if instead of being displayed in the bar of the website browser.com/help? go=Faq, etc. were help.site.com/Faq. I know this is possible if you made the directory "help" and I pointed the subdomain there, but I wanted it directly in the file already ready.

  • @Junior, there’s no answer clearer than mine.

  • See here, we probably already have an answer on the site, what you are looking for is a friendly URL: http://answall.com/search?q=qURL+amigavel+htaccess

  • Just to comment if someone else needs this type of solution, simpler than all this is to configure the server to treat files with no extension as PHP, so already solve without . htaccess - It can be impractical in a very complex application that is already ready, but to start from scratch, it can be a good one, as long as one has control over the hosting.

Show 1 more comment

1 answer

0

Your link tags and the way you will open your content, you will have to change it yourself. So where you used:

ajuda.php?go=faq

Now you will write:

ajuda.php/faq

Its rules need to translate the friendly into the querystring.

RewriteRule ^([a-z]+)\/?$ ajuda.php?go=$1 [NC,L]

It’s very simple to do this. I recommend a reading here.

  • I’m not the one who said no, I don’t know why, but I guess this ajuda.php/faq is wrong, as your RewriteRule ^([a-z]+)\/?$ access should be http://site/faq/ just, no?

  • 1

    The guy wants to trade for the subdomain, which would require more than HTACESS, it would be necessary a DNS configuration that the Index of this domain pointed to the search!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.