php - Internal Server Error: Having trouble with mod_rewrite in .htaccess

334

My URL is like this:

http://example.com/Folder/index.php?city=Berlin&id=1

I want to turn it into:

http://example.com/Berlin/1

Using Generate It! I get this code:

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /Folder/index.php?city=$1&id=$2 [L]

But when adding this in my .htaccess file and trying to openhttp://example.com/Berlin/1 I'm getting the following error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [no address given] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache/2.2.14 (Ubuntu) Server at example.com Port 80

What am I doing wrong? I'm trying since hours to get it work, but without success.

10

Answer

Solution:

I found the solution:

I'm using this in my.htaccess:

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/id/([^/]*)$ /Folder/index.php?city=$1&title=$2&id=$3 [L]

to change this link:

http://example.com/Folder/index.php?id=566&city=Berlin&title=this_is_the_websites_title

to:

http://example.com/Berlin/this_is_the_websites_title/id/566

People are also looking for solutions to the problem: php - Canit insert into my MYSQL table

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.