1

think the user enter

localhost/app/public/anything/anything/index/php/id/5 

then id like to change it to the

localhost/app/public/index.php?id=5 

the expression that i wrote is this

RewriteRule ^index/php/id/([0-9]+)$ http://localhost/saecms/public/index.php?id=$1 [L]

but it doesn't work, whats wrong here? thank you

5
  • 1
    I smell incoming answer from anubhava, one of the only 3 users with gold badge in .htaccess so I'm not posting mine Commented Sep 6, 2015 at 17:40
  • 1
    @DeDee That was quite funny :) Commented Sep 6, 2015 at 17:42
  • @DeDee: Feel free to post an answer to provide me pleasure of upvoting your answer. Commented Sep 6, 2015 at 17:43
  • 1
    @anubhava I'd rather see if I could learn from you, go for it :) Commented Sep 6, 2015 at 17:43
  • man, i tried many expression but i cant solve it, i'm new with this , i don't know why when i use / this in the regex nothing work correctly Commented Sep 6, 2015 at 17:46

1 Answer 1

1

You can use this rule in your /app/public/.htaccess file:

RewriteEngine On RewriteBase /app/public/ RewriteRule (?:^|/)index.php/id/(\d+)/?$ index.php?id=$1 [L,QSA,NC] 
Sign up to request clarification or add additional context in comments.

5 Comments

there is another problem here that i cant fix it, sorry to ask. the css file and some images doesn't load, the path is localhost/app/public/something/something/news/php/id/js/jquery.js how can i fix this??
That might be due to your use of relative paths. How are those css/js being included in your HTML?
<link href="css/bootstrap.min.css" rel="stylesheet"> all of the css file are included like this
ok so you're including it as <link href="css/bootstrap.min.css" rel="stylesheet"> and actual working path is http://localhost/app/public/css/bootstrap.min.css ?
by adding this tag, everything work well now <base href="http://localhost/app/public/" target="_blanck"> thanks you for help.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.