NameSilo

Mod rewrite help needed

SpaceshipSpaceship
SpaceshipSpaceship
SpaceshipSpaceship
Watch
Impact
58
How do I use htaccess to make these web pages:

http://pcflyinggames.com/?home
http://pcflyinggames.com/?k=Flying Games
http://pcflyinggames.com/?k=Flight Simulator
http://pcflyinggames.com/?k=Flight Shooter
http://pcflyinggames.com/?k=Flight combat
http://pcflyinggames.com/?k=Helicopter Sim
http://pcflyinggames.com/?k=sci-fi

to look like this in a browser:

http://pcflyinggames.com/
http://pcflyinggames.com/flying-games
http://pcflyinggames.com/flight-simulator
http://pcflyinggames.com/flight-shooter
http://pcflyinggames.com/flight-combat
http://pcflyinggames.com/helicopter-sim
http://pcflyinggames.com/sci-fi-games

I have been pulling my hair out trying to figure it out and all I get is errors.
This is an example of how I was going about it for just one of my pages, and it did not work.

# Enable Rewrite Engine
RewriteEngine on
#Create SEO friendly URL
RewriteRule
RewriteRule ^pcflyinggames.com/flying-games/$ pcflyinggames.com/?k=Flying Games
 
Last edited:
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
htaccess cannot change the links in pages however the links that you wish to be redirected will be redirected with the following htaccess.

Code:
RewriteEngine on

RewriteRule ^([-a-zA-Z]+)$ index.php?k=$1 [L]

You do not need a new rule for each link. The above rewrite rule will match anything as long as it only contains letters and a -.
 
0
•••
Thanks for trying, but it did not work.

I am trying to make the pages look better and also it's supposed to be better for SEO.
 
0
•••
the code I posted does exactly as intended (used it myself)

If you are trying to use htaccess to change the links on the page itself it is not possible. htaccess only redirects people that go to certain URL's.

Therefore in the pages themselves you would need to set the links to go to Sci-fi-games - Flying Games etc (apart from the lin ks nothing else needs changing) and the htaccess will redirect them to the real url when visitors use the links.
 
0
•••
It's still there. Never did figure out how to get rid of the "?"
 
0
•••
should of requested this in development stage :)
this is the correct code
Code:
RewriteEngine on

RewriteRule ^([-a-zA-Z]+)$ index.php?k=$1 [L]
it works: http://pcflyinggames.com/flight-combat
just need to change the links in index.php (just remove ?k=);)
 
0
•••
Thank for the help nodws.
I did not really notice during development stage. I had alot going on during that time period.
I also have alot of sites, and it always seems something that needs fixed or tweaked or changed or something. Most of the time I can figure it out myself, but this one had me stumped.

Everything working now except I cant get rid of "?home"
when you type in www.pcflyinggames.com it resolves to www.pcflyinggames/?home
I want it to be www.pcflyinggames.com

I have tried everything I can think of but no luck. I change it in index.php it breaks the script. Do you have any
ideas?
 
Last edited:
0
•••
you need "home", or you will get come-along winch ads, its the only work around I´ve found.
 
0
•••
Thank for the help nodws.
I did not really notice during development stage. I had alot going on during that time period.
I also have alot of sites, and it always seems something that needs fixed or tweaked or changed or something. Most of the time I can figure it out myself, but this one had me stumped.

Everything working now except I cant get rid of "?home"
when you type in http://www.pcflyinggames.com it resolves to http://www.pcflyinggames/?home
I want it to be PC Flying Games - Flying Games

I have tried everything I can think of but no luck. I change it in index.php it breaks the script. Do you have any
ideas?
For the problem relating to redirection from / to /?home, may be your script is buggy. It does'nt seem to be a problem with htaccess.

The htaccess code suggested above should work well. If it doesnt, show us what you have in htaccess. Copy everything from htaccess here.

Also make sure that you have mod_rewrite enabled in your apache config file to make above suggested rewrite rules work.
 
0
•••
mod_rewrite is enabled in the apache config file.

Here is the contents of htaccess

RewriteEngine on
ErrorDocument 404 /404.html
RewriteRule ^([-a-zA-Z]+)$ index.php?k=$1 [L]

Also just noticed that 404.html is not working

If I type in something random like:
pcflyinggames.com/xxx

then I dont get my 404 file:
404
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back