Think your links look ugly eg.
www.yoursite.com/index.php?page=test&skin=blue&language=eng&time=uk
Well .htaccess has made it alot easier for you to change this to something like;
www.yoursite.com/test/blue/eng/uk/
What is .htaccess?
Taken from; http://en.wikipedia.org/wiki/Htaccess.htaccess (hypertext access) is the default name of Apache's directory-level configuration file. It provides the ability to customize configuration for requests to the particular directory.
.htaccess files are commonly used for:
- Authorization, authentication: .htaccess files are often used to specify the security restrictions for the particular directory, hence the filename "access". The .htaccess file is often accompanied by an .htpasswd file which stores valid usernames and their passwords.
- Customized error responses: Changing the page that is shown when a server-side error occurs, for example HTTP 404 Not Found.
- Rewriting URLs: Various server-side PHP scripts use .htaccess to rewrite "ugly" URLs to shorter and prettier ones.
Here's how you can do it.
So first of all we turn on and make sure all the links follow.
Now this is where it gets hard, lets just test with one,Code:Options +FollowSymLinks RewriteEngine On
this will change yoursite.com/index.php?page=test to yoursite.com/test/ (remember the last / ).Code:RewriteRule ^([A-Za-z0-9-]+)/$ index.php?page=$1 [L]
Now we will do the rest,
RewriteRuleYou will need to save that in the appropriate directory.Code:^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/$ index.php?page=$1&skin=$2&language=$3&time=$4 [L]
Code breakdown,
This allows it to either be UPPERCASE lowercase or BoTh or numbers (0-9)Code:([A-Za-z0-9-]+)
you can allow it just for numbers,
Code:([0-9]+)the $1 means that its the first in the url, like yoursite.com/first/second/thirdCode:page=$1i think thats all enjoy.
OR you could use RichardKnox method which is also very good and easier to use thanks,
You overcomplicated it.
http://www.yoursite.com/index.php?pa...ge=eng&time=uk
to
www.yoursite.com/test/blue/eng/uk/
doesn't require as much as you;ve put. Try
Code:
RewriteEngine On
RewriteRule (.*)/(.*)/(.*)/(.*)/ index.php?page=$1&skin=$2&language=$3&time=$4
UPDATE:
Iv had a few PMs asking me how to access .htaccess so heres how:
Log into Cpanel and click on "File Manager". You should then get a pop-up asking which directory to open, if you look a bit further down on the pop-up you should see two Check boxs. Check "Show Hidden Files" and click "Go".
Now go to www if your not allredy in there, and you should see .htaccess
[ Credit to .:Jack120:. ]
Edited By Sunny. (Forum Moderator): Updated as requested.






i think thats all enjoy.
Reply With Quote

