Tell me more ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

How can I rewrite my URL from edit.php?id=2 to edit/id/2?

share|improve this question
you mean /edit/id/2 => edit.php?id=2 – Book Of Zeus Nov 14 '11 at 3:14

migrated from stackoverflow.com Nov 14 '11 at 11:55

2 Answers

up vote 10 down vote accepted

Try this

RewriteEngine On
RewriteBase /
RewriteRule ^edit/id/([0-9]+)/?$ edit.php?id=$1 [NC,QSA,L]
share|improve this answer
It works but my styles.css and other images doesn't load coz the location has changed. – cloud 9 Nov 14 '11 at 3:26
do you have other rules? what is the URL for the style.css? – Book Of Zeus Nov 14 '11 at 3:31
I added a variable in my includes like <?php echo $currentdir;?>/niceforms.js but niceform.js generates img/0.png and img/0.png don't load. – cloud 9 Nov 14 '11 at 3:38
and img/0.png is located in : edit/id/? – Book Of Zeus Nov 14 '11 at 3:40
This should be the location of "img/0.png" in my php output.My img folder is the same location as edit.php img/0.png but the result is edit/id/img/0.png – cloud 9 Nov 14 '11 at 3:45
show 4 more comments

in case you need:

http://yoursite.com/subpage1/subpage2/?YOURSTRING=blabla

to redirected visitor to

http://yoursite.com/subpage1/subpage2/

then in the beggining of .htaccess, insert:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} YOURSTRING=(.*)
RewriteRule ^(.*)$ /$1? [R=301,L]
</IfModule>

## if wordpres isnot installed in root folder, then edit the fourth line like this
RewriteRule ^(.*)$ /YOUR-WORDPRESS-DIRECTORY/$1? [R=301,L]
share|improve this answer
Instead of putting a link to answer the question, could you write the answer here? – j0k Mar 28 at 14:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.