Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess basic mod rewrite

Tags:

.htaccess

I am only just starting to learn how to rewrite urls with the .htaccess file.

How would I change:

http://www.url.net/games/game_one.php

into this:

http://www.url.net/games/game-one/

This is what I have been trying

RewriteRule    ^/games/game-one.php    ^/games/game-one/    [NC,L]
like image 208
Amy Neville Avatar asked Feb 02 '26 05:02

Amy Neville


1 Answers

If you want people to use /games/game-one/ explicitly, you have to rewrite so that it requests /game/game-one.php. So the opposite way around than you have it in your question.

RewriteEngine On
RewriteRule ^games/game-one/$ /games/game-one.php

If you want to rewrite other URL's too, then you'd need to use a technique similar to the prior answer.

like image 151
nickhar Avatar answered Feb 03 '26 21:02

nickhar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!