Reputation: 8720
I am working using php and apache server, I want to rewrite sites/all/themes/chap2014/fpd/gift.php
to fdp/gift
and sites/all/themes/chap2014/fpd/another.php
fdp/another
exactly I want do this
rewrite sites/all/themes/chap2014/fpd/*.php
to fpd/*
rewrite mode is enable and I try below code in .htacess
file.
RewriteEngine on
RewriteRule ^fpd/?$ sites/all/themes/chap2014/fpd/$1.php
but nothing happened,what is the correct way to achieve this ?
Appreciate any help,
Upvotes: 1
Views: 71
Reputation: 577
Try this:
RewriteRule ^fpd/(.+)$ sites/all/themes/chap2014/fpd/$1.php
You might want to exclude the /
symbol, if so, then replace the .+
with [^/]+
.
You have to enclose the part that you want placed into a variable with ()
, and each enclosed part will be put into $1, $2, $3 and so on.
Also, here is a nice tool to test your rewrite rules:
http://martinmelin.se/rewrite-rule-tester/
Upvotes: 2
Reputation: 786091
You need to first group and capture part of URI on LHS of URI pattern before you can use $1
, $2
etc on RHS.
RewriteEngine on
RewriteRule ^fpd/([^/]+)/?$ /sites/all/themes/chap2014/fpd/$1.php [L,NC]
PS: In your question you have used both fpd
and fdp
. Not sure which one is right.
Upvotes: 2