Jump to content


.htaccess url rewrite help


4 replies to this topic

#1 Blambu

    Young Padawan

  • Members
  • Pip
  • 17 posts

Posted 13 July 2009 - 02:16 PM

Hey,

I'm after some help with the following .htaccess code:
Options +Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)$ profile.php?username=$1 [L]

I just can't get it to work, I want to be able to go to myurl.com/myusername and it will show my account.

Also, how would I go about making /about go to about.php

Any help would be greatly appreciated.



:)

#2 Blambu

    Young Padawan

  • Members
  • Pip
  • 17 posts

Posted 14 July 2009 - 06:02 AM

Still not got this to work :)

#3 Rcty

    Young Padawan

  • Members
  • Pip
  • 3 posts
  • Gender:Male

Posted 19 July 2009 - 11:19 PM

Sorry, I can't help you with your first question, but making /about go to about.php is fairly simple. You can have more than one RewriteRule in an .htaccess file. You should be able to do that by just adding this to your code:

RewriteRule ^about$ about.php [L]


#4 Jurnky

    Young Padawan

  • Members
  • Pip
  • 84 posts

Posted 20 July 2009 - 10:05 AM

This will work:

RewriteEngine On
RewriteBase /
RewriteRule ^()$ index.php [NC,L]
Rewritecond %{REQUEST_URI} !(^/?.*\..*$) [NC]
RewriteRule (.*)$ $1.php [NC]

ErrorDocument 404 /404

Just be sure that in the mark up, you write <a href="myurl.com/about"> instead of <a href="myurl.com/about.php"> and the .php extension will be removed.

Edited by Jurnky, 20 July 2009 - 10:05 AM.


#5 Blambu

    Young Padawan

  • Members
  • Pip
  • 17 posts

Posted 21 July 2009 - 08:57 AM

View PostJurnky, on Jul 20 2009, 04:05 PM, said:

This will work:

RewriteEngine On
RewriteBase /
RewriteRule ^()$ index.php [NC,L]
Rewritecond %{REQUEST_URI} !(^/?.*\..*$) [NC]
RewriteRule (.*)$ $1.php [NC]

ErrorDocument 404 /404

Just be sure that in the mark up, you write <a href="myurl.com/about"> instead of <a href="myurl.com/about.php"> and the .php extension will be removed.


Thanks mate,

That has put me right in the direction I'm meant to be heading. Any clue how I'd then be able to use it as a varilable in my PHP.

Say I want to capture from the url the username, say $username = $_GET['WHAT HERE?'];


Thanks for your continuing support :) Highly appreciated!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users