I'm playing with the .htaccess and I'm wondering if there is a way to take a URL like this one:
(This URL points to a php file that queries a data base. The data base for that has a column for "id" and a column for "sef". In this case "id" = "1000" and "sef" = "prescott-valley-arizona")
Can .htaccess be used to rewrite URL to:
if so how? any help will be appreciated
For the section of the site that I want to do this for, I am not using any CMS. I'm just coding with MySQL and PHP
The answer is a resounding YES! (But ONLY if you have access to the server and/or VirtualHost config file.) The mod_rewrite statement is RewriteMap which is only available via those config files, not .htaccess.
Don't despair, though, as you can use your own "redirect" (PHP) script to do the same thing so long as there is no output before a header("location:yadda-yadda"); command.
Thanks for the response. Sounds like you've got some real experience in this.
I'm not entirely sure I have access to the server in that way nor am I sure whether I have access to the VirtualHost config file. I am on a reseller account through HostGator and they use CPanel/WHM, but aside from setting up new hosting accounts I have never played with any of the settings.
I do not have an output command before the header. So if it turns out that I don't have access to the Virtual Host config file, then the redirect script you're suggesting may have to be my only alternative.
Can you point me in the tight direction? Cuz I'm not entirely sure what I should do from here.
If you're on a hosted account (and NOT a dedicated server), you should NOT have access to the configuration files (because even a minor syntax error can bring the server down for EVERYONE).
That said, I'm sure that you're stuck with the PHP solution which is very nearly identical to the RewriteMap solution (except that it's ALL done with PHP, not a PHP "program" executed by mod_rewrite; the difference is in returning the header() rather than a simple text output for the redirection by mod_rewrite).