This is the first time I have ever tried to use mod_rewrite and have been stuck for a couple days. I am trying to change

www.mysite.com/example6.php?id=games

to

www.mysite.com/example6/games

Is this even achievable? Any advice will be very much appreciated!

I have searched this forum and have done extensive google search and have not been able to figure it out. I have many links that look like:

http://www.mysite.com/example6.php?id=play-game
http://www.mysite.com/example6.php?id=watch-tv
http://www.mysite.com/example6.php?id=go-outside

I have tried lots of different code putting this in my .htaccess file:

Options +FollowSymLinks
Options +Indexes
RewriteEngine On
RewriteRule ^([^/]*)\.html$ /example6.php?id=$1 [L]

and

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^id/(.*) example6.php?id=$1
</IfModule>

and many more attempts but nothing works to get my URLS to look like this:

http://www.mysite.com/example6/play-game
http://www.mysite.com/example6/watch-tv
http://www.mysite.com/example6/go-outside

I do have mod_rewrite enabled on my server. Does anyone have any ideas? Thanks in advance.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^example6/([^/]+)$ example6.php?id=$1 [L]

Does that work? Haven't tested it so I might of forgotten something. Just wrote it from memory.

No, I have also tried

RewriteRule ^(.*?)/(.*) example6.php?id=$1&id2=$2

and

RewriteRule ^example6/(.*)$ /example6.php?id=$1 [L]

Does it matter where I upload my .htaccess file to? Thanks much

I would say just putting it in the document root would be ideal.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.