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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.