Jump to content

mod_rewrite problem


scar5308

Recommended Posts

In a bid to get my new site search engine friendly as the site was not being indexed properly, I have used mod_rewrite to rewrite the urls. So far, so good. However, I am having a problem with rewriting the arrays. I have written my menu items like so:

[code]href="homepage-language-<?=$lang?>.html">[/code]
with the original url as:
[code]href="homepage.php?language=<?=$lang?>">[/code]

This produces the url:

[code]http://www.site.co.uk/homepage-language-en.html[/code]

this works fine with a rewrite rule:

[code]Options +FollowSymLinks
RewriteEngine on
RewriteRule homepage-language-(.*)\.html$ homepage.php?language=$1[/code]

My problem is that I have a language switch using the code:

[code]<select name="select" onchange="self.location='http://www.site/homepage.php?language='+this.options[this.selectedIndex].value">[/code]

This allows the user to select a different language from a list. This is the part that is giving me trouble as when a different language is sellected, it produces the URL:

[code]http://www.site/homepage.php?language=de[/code]

How can I make it produce the URL as above?:

[code]http://www.site.co.uk/homepage-language-en.html[/code]

Obviously quite a simple problem with a different rewrite rule but how?

Also, is there a rewrite rule that would  allow the part where 'homepage' is to allow any other page title such as contactus or bookings. or would this be a security problem?

Thanks in advance
Link to comment
https://forums.phpfreaks.com/topic/29842-mod_rewrite-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.