HTACCESS - can you modify /hello ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

HTACCESS - can you modify /hello ?

Post by simonmlewis »

[text]RewriteRule ^manufacturers/([^/]+) /index.php?page=manufacturers&menu=home&manufacturer=$1 [L]

RewriteRule ^([^/\.]+)/?$ index.php?page=$1&menu=home [L]
RewriteRule ^$ index.html [L][/text]

We have a site that uses HTACCESS, but we are building foreign versions. While I need the filenames to be in English, such as /products, we want the URLs to be in the foreign language.

Can you do a /page per file?

So www.thiswebsite.es/preguntas, takes you to www.thiswebsite.es/index.php?page=faq ??
We have about a dozen of these pages that need doing.

Thanks.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: HTACCESS - can you modify /hello ?

Post by Celauran »

You can do one entry per page if needed. Since you're already routing everything to a single page, you may want to look into adding a router to handle all these requests for you.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: HTACCESS - can you modify /hello ?

Post by simonmlewis »

How?
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: HTACCESS - can you modify /hello ?

Post by Celauran »

Something like this maybe?

Code: Select all

RewriteRule ^(first-page|second-page|third-page)(/)?$ index.php?page=$1 [QSA, L]
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: HTACCESS - can you modify /hello ?

Post by simonmlewis »

Thanks for that.
How does it know that "preguntas" is opening faq.inc ??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: HTACCESS - can you modify /hello ?

Post by Celauran »

Oh right, the translation. My bad. Forgot about that.

Code: Select all

RewriteRule ^preguntas/?$ index.php?page=faq [L]
RewriteRule ^otherpage$ index.php?page=tomatoes [L]
etc
Post Reply