Clean URL's With .htaccess (How To)

  • techwiz
  • Beginner
  • Beginner
  • User avatar
  • Posts: 46

Post 3+ Months Ago

Hello All...

I have been tinkering with some .htaccess code for a while now i cant seem to get it to work...

I would like my urls:

example[dot]com/index.php?x=media

to be rewritten to:

example[dot]com/media

....

The folder media does not exist...

so there must be a way to "cloak" the ugly url with the "?" in it and mask it.

It would need to convert the url with the "?" in it to the nice url.

and realize incoming connections to example[dot]com/media actually points to example[dot]com/index.php?x=media, however it shows the nice one...

Is it even possible?
EDIT: ==============
I know its possible now, I got a bit working but its got a few bugs:

#.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f #this line asks apache "is there a file with the name $1?"
RewriteCond %{REQUEST_FILENAME} !-d #this line asks apache "is there a directory with the name $1?"
# if both are no, than call the index file
RewriteRule ^(.*)$ index.php?x=$1 [L,QSA]
# http://domain/about -> http://domain/index.php?x=about

This code works for all pages except when you don't put anything after the example[dot]com/<nothin here>

It does not call index.php, it calls index.html.


Edit 2: =============

Never mind I got it working WOOT!!!!

I just had to change the order of directory index significance!:

DirectoryIndex index.php index.html index.htm default.htm index.php default.html


Magic, well Thanks.
Happy .htaccessing!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • mardeny
  • Born
  • Born
  • mardeny
  • Posts: 1

Post 3+ Months Ago

New here and frist time to join in.Hope i can learn more things from all of you.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 21 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.