Imrul.H
Imrul.H

Reputation: 5870

using htaccess to modify URL

I am working on a php project. I want to remove the ".php" from the URL. Also for -

www.mysite.com/gallery.php?gid=2008

I want like -

www.mysite.com/gallery/2008

How can I do this? I want to check it in local wamp server also.

Upvotes: 1

Views: 390

Answers (5)

Zimbabao
Zimbabao

Reputation: 8250

Enable the mod_rewrite in wamp And add following lines in .htaccess of your document root

RewriteEngine On
RewriteRule gallery/([0-9]+)/?$ gallery.php?gid=$1 [L]

If you want to remove all other PHP but retaining query string, if you have specifc way to handle query string you have write rules accordingly.

RewriteRule (.*)/? $1.php [QSA,L] 

Upvotes: 2

Mohammad Efazati
Mohammad Efazati

Reputation: 4930

really multiple question

please search

Upvotes: 1

awm
awm

Reputation: 6580

Here is an easy way to allow the URL without .php:

Options +MultiViews

Upvotes: 1

Raj
Raj

Reputation: 22956

Add the following in your .htaccess

RewriteEngine On
RewriteRule ^(.*)\.php\?(.*)=(\d+)$ /$1/$2

Upvotes: 0

Abdel Raoof Olakara
Abdel Raoof Olakara

Reputation: 19353

Have a look at this guide.. this should help you get started: http://corz.org/serv/tricks/htaccess2.php

Upvotes: 1

Related Questions