Dido123
asked on
Managing Dynamic Content using Rewrite in .htaccess file
Hi,
I have a website where I'll be creating a dynamic page for each country once I have enough info about it. So I wouldn't start off with all countries I'm using RewriteRule in .htaccess since it's a dynamic content which pulling data from MySQL database. The pages like :
www.mywebsite.com/us/
www.mywebsite.com/uk/
etc..
and in the htaccess I do something like this : RewriteRule us/$ content.php?id=us
Now, my problem is, I have to create a new line in my htaccess for each country I decide to put its page up So it would give an 404 error for any country I'm not ready to publish the content of it yet.
Is this the best way to handle this situation or do you have any other suggestions? Since right now I might have 15 countries ready but I'll be heading to over 165 countries later and I'll have to do it separately for each one.
Thank you so much in advance for helping me out here.
I have a website where I'll be creating a dynamic page for each country once I have enough info about it. So I wouldn't start off with all countries I'm using RewriteRule in .htaccess since it's a dynamic content which pulling data from MySQL database. The pages like :
www.mywebsite.com/us/
www.mywebsite.com/uk/
etc..
and in the htaccess I do something like this : RewriteRule us/$ content.php?id=us
Now, my problem is, I have to create a new line in my htaccess for each country I decide to put its page up So it would give an 404 error for any country I'm not ready to publish the content of it yet.
Is this the best way to handle this situation or do you have any other suggestions? Since right now I might have 15 countries ready but I'll be heading to over 165 countries later and I'll have to do it separately for each one.
Thank you so much in advance for helping me out here.
You don't create new line you provide once so everytime country changes based on the parameter it also depends how you are getting the country name on the page is it coming from database
ASKER
I send the required data (including the country name) using POST in the url like this :
RewriteRule us/$ content.php?id=us&name=Uni ted+States &nationali ty=America n&continen t=North+Am erica
I know that I can pull the other info using MySQL but I do it that way since I need to send country id anyway.
RewriteRule us/$ content.php?id=us&name=Uni
I know that I can pull the other info using MySQL but I do it that way since I need to send country id anyway.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The best option to write a PHP script that will generate the .htaccess [or a text file that you can rename it to .htacess] file as the requirement is dynamic. The script can handle this elegently.
Hope this helps
Hope this helps